Getting "EnclosingMethod" errors when creating in Android Studio 2

I get below build errors when I run the application in Android Studio 2. These errors were not there when I used an earlier version of 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. 

What are these errors and how to resolve them? In addition, apk builds great, and the app also works great.

+30
Apr 21 '16 at 7:36
source share
4 answers

Update 2016/09/19

This is fixed in LeakCanary 1.4, so a simple update should fix it without contacting the alternative version of haha .

 debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4' 

Earlier

These warnings are caused by haha:2.0.2 , which is a dependency on leakcanary-android:1.4-beta2 .

It is fixed in haha:2.0.3 , so you can fix it by explicitly using the newer version in your dependencies. Add this line for each flavor where you add a leakcanary dependency. You do not need to add it for leakcanary-android-no-op , since it has no dependencies.

 debugCompile 'com.squareup.haha:haha:2.0.3' 
+30
Jul 07 '16 at 21:45
source share

Adding

-keepattributes EnclosingMethod

for the proguard configuration file (in my case proguard.cfg ), it seems to fix this.

+15
Aug 24 '16 at 19:33
source share

I was getting the same error. There seems to be a leak problem (in my case). I tried the following changes to the proguard file.

 -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 

I no longer get this problem. Here's the link

+5
May 2 '16 at 7:34 a.m.
source share

I solved the problem by adding the following dependency to my build.gradle:

testCompile "com.squareup.leakcanary: leakcanary-android-no-op: 1.4-beta2"

link here: https://github.com/square/leakcanary/issues/491

+2
May 04 '16 at 1:42
source share



All Articles