Android警告 - 忽略InnerClasses属性(jnamed)

时间:2016-11-08 11:39:45

标签: android android-studio warnings proguard

在Android Studio中构建代码时出现此警告。
很少有时候它们不会出现,但大多数时候都会出现。

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(或任何其他方式)中隐藏此警告。谢谢!

2 个答案:

答案 0 :(得分:2)

什么原因造成问题?

您正在尝试在运行Android的运行时Dalvik的JVM中使用未针对Java 6或7编译的类文件。这不是一个大问题,你不必担心。

我该如何解决?

您可以重新编译导致该问题的库。不幸的是,该库已经在一个已编译的jar中。您可以尝试在线查找其来源,然后编译

答案 1 :(得分:2)

您是否考虑过更新JDK和JRE?另外,您是否已将Android studio更新到最新版本?执行这些任务中的任何一个都可以解决问题。另外,在sdk manger中卸载并重新安装proguard可能会有所帮助。