2016-11-08 127 views
4

我在Android Studio中構建我的代碼時遇到此警告。
幾次他們沒有出現,但他們大多數時間。Android警告 - 忽略InnerClasses屬性(jnamed)

warning: Ignoring InnerClasses attribute for an anonymous inner class 
(jnamed$1) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 
warning: Ignoring InnerClasses attribute for an anonymous inner class 
(jnamed$2) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 
warning: Ignoring InnerClasses attribute for an anonymous inner class 
(jnamed$3) that doesn't come with an 
associated EnclosingMethod attribute. This class was probably produced by a 
compiler that did not target the modern .class file format. The recommended 
solution is to recompile the class from source, using an up-to-date compiler 
and without specifying any "-target" type options. The consequence of ignoring 
this warning is that reflective operations on this class will incorrectly 
indicate that it is *not* an inner class. 

我讀過的其他問題,其中包括這些在我的ProGuard文件:

-keepattributes EnclosingMethod 
-keepattributes InnerClasses 

但是他們並沒有幫助。

編輯:

如果這是不可能解決這個問題,請告訴我如何隱藏在postguard此警告(或任何其他方式)。謝謝!

+0

嗨,你有沒有看到這個? http://stackoverflow.com/questions/30999337/android-studio-and-gradle – Jaco

+0

嗨。不,我沒有,但那不相關。它沒有幫助。請刪除我的問題的投票,以便我可以在這裏得到答案。謝謝! –

+0

對不起GyörgyBenedek,我沒有加你倒票 – Jaco

回答

2

Whats cause the problem?

您正嘗試在運行Android運行時Dalvik的JVM中使用未針對Java 6或7編譯的類文件。這不是一個大問題,你不必擔心。

我該如何解決?

您可以重新編譯導致問題的庫。不幸的是,該庫已經在編譯的jar中。您可以嘗試在線查找源代碼,然後編譯該代碼

+0

我只使用一個罐子,那就是dnsjava。 https://sourceforge.net/projects/dnsjava/這可能導致問題?沒有更新的版本,正如我所看到的,我已經使用了2.1.7。在postguard中是否有可能選擇隱藏此警告? –

+0

dnsjava中的Jnamed引發了這個問題。如果你看它的源代碼http://dnsjava.org/dnsjava-current/jnamed.java,它聲明它是在2004年創建的。在你的項目中創建一個名爲org.xbill.DNS.programs的包,並在你的項目中創建一個名爲Jnamed的類該包與來自源代碼。這應該解決問題 –

+0

該修復程序無法正常工作,但是您發現警告的來源。謝謝,我給你賞金! :) –

2

您是否考慮過更新JDK和JRE?此外,你有沒有更新Android工作室到最新版本?執行這些任務可能會解決問題。在sdk管理器中卸載並重新安裝proguard可能會有所幫助。

+0

Android Studio是最新的,我總是安裝推薦的更新,在開始時彈出。我在3臺不同的計算機上使用Android Studio,並且都有問題,所以這可能不起作用,但我會試一試,謝謝! :) –