在Android Studio 2中构建时出现"EnclosingMethod"错误

Ami*_*ari 30 android android-studio-2.0

当我在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.
Run Code Online (Sandbox Code Playgroud)

这些错误是什么以及如何解决?此外,apk正在建设正常,该应用程序也运行完美.

Sky*_*sey 30

更新2016/09/19

这在LeakCanary 1.4中得到修复,因此只需升级就可以修复它而无需乱用其他版本haha.

debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4'
Run Code Online (Sandbox Code Playgroud)

先前

这些警告是由haha:2.0.2一个依赖引起的leakcanary-android:1.4-beta2.

它已修复haha:2.0.3,因此您可以通过在依赖项中显式使用较新版本来修复它.为要添加leakcanary依赖项的每种flavor添加此行.您不需要添加它leakcanary-android-no-op,因为它没有依赖项.

debugCompile 'com.squareup.haha:haha:2.0.3'
Run Code Online (Sandbox Code Playgroud)

  • 这是摆脱这种烦人警告的最简单方法.谢谢 (2认同)

fat*_*ire 15

添加

-keepattributes EnclosingMethod

proguard的配置文件(在我的情况下,proguard.cfg)似乎修复了这个问题.


Abh*_*dar 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
Run Code Online (Sandbox Code Playgroud)

我不再接受这些问题了.这是链接