30

I am getting below build errors when I am running the app in Android Studio 2. These errors were not there when I was using 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? Also, the apk is building fine and the app also runs perfectly.

fattire
  • 5,004
  • 2
  • 18
  • 32
Amit Tiwari
  • 3,478
  • 6
  • 26
  • 69
  • 1
    did u try clean->rebuild – Lokanath Apr 21 '16 at 07:37
  • @Lokanath yes, I tried that already. – Amit Tiwari Apr 21 '16 at 07:38
  • Got the solution from here while searching about the problem : http://stackoverflow.com/a/36523016/1263362 – Sayem Sep 20 '16 at 09:38
  • 1
    Possible duplicate of [Large number of errors during Gradle build after upgrading to Android Studio 2.0](http://stackoverflow.com/questions/36522313/large-number-of-errors-during-gradle-build-after-upgrading-to-android-studio-2-0) – Sayem Sep 20 '16 at 09:40

4 Answers4

30

Update 2016/09/19

This is fixed in LeakCanary 1.4, so simply upgrading should fix it without needing to mess with an alternate version of haha.

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

Previously

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

It's 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 are adding a leakcanary dependency. You don't need to add it for leakcanary-android-no-op, since it has no dependencies.

debugCompile 'com.squareup.haha:haha:2.0.3'
Sky Kelsey
  • 18,682
  • 5
  • 34
  • 72
15

Adding

-keepattributes EnclosingMethod

to proguard's configuration file (in my case, proguard.cfg) seems to have fixed this.

fattire
  • 5,004
  • 2
  • 18
  • 32
  • Debug builds don't usually build w/proguard (because it takes so long, so most configs don't have it on).. but I suppose it should... – fattire Nov 11 '16 at 08:55
5

I was getting same error. It seems there was some problem with leakcanary (in my case). I tried following changes in 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 am not getting those issue anymore. Here is the link

Abhishek Patidar
  • 1,548
  • 1
  • 15
  • 24
2

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

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

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

Miceking
  • 21
  • 3