当我在Android Studio 2中运行应用程序时,我遇到了构建错误。当我使用早期版本的Android Studio时,这些错误并不存在。
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(com.squareup.haha.guava.base.Joiner$1) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(com.squareup.haha.guava.collect.Iterables$2) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(com.squareup.haha.guava.collect.Iterables$3) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.
这些错误是什么以及如何解决?此外,apk正在建设正常,应用程序也运行完美。
答案 0 :(得分:30)
这已在LeakCanary 1.4中修复,因此只需升级即可修复它,而无需使用haha
的备用版本。
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4'
这些警告是由haha:2.0.2
引起的,leakcanary-android:1.4-beta2
是haha:2.0.3
的依赖关系。
它已在leakcanary
中修复,因此您可以通过在依赖项中显式使用较新版本来修复它。为要添加leakcanary-android-no-op
依赖项的每种flavor添加此行。您不需要为debugCompile 'com.squareup.haha:haha:2.0.3'
添加它,因为它没有依赖项。
Rewrite
答案 1 :(得分:15)
添加
-keepattributes EnclosingMethod
到proguard的配置文件(在我的例子中,proguard.cfg
)似乎已经解决了这个问题。
答案 2 :(得分:5)
我得到同样的错误。泄漏事件似乎存在一些问题(在我的情况下)。我尝试跟踪proguard文件中的更改。
-dontwarn com.squareup.haha.guava.**
-dontwarn com.squareup.haha.perflib.**
-dontwarn com.squareup.haha.trove.**
-dontwarn com.squareup.leakcanary.**
-keep class com.squareup.haha.** { *; }
-keep class com.squareup.leakcanary.** { *; }
# Marshmallow removed Notification.setLatestEventInfo()
-dontwarn android.app.Notification
我不再处理这些问题了。这是link
答案 3 :(得分:2)
我通过在build.gradle中添加以下依赖项解决了这个问题:
testCompile“com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2”