Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proguard fails on 1.4-SNAPSHOT #265

Closed
kkocel opened this issue Aug 31, 2015 · 27 comments
Closed

Proguard fails on 1.4-SNAPSHOT #265

kkocel opened this issue Aug 31, 2015 · 27 comments
Milestone

Comments

@kkocel
Copy link

kkocel commented Aug 31, 2015

I've got this:

Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$1: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$Itr
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$2: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$Itr
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$RandomAccessWrappedList: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$RandomAccessWrappedList: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedList
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$SortedAsMap: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$AsMap
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$SortedKeySet: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$KeySet
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedList: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedList: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedList$WrappedListIterator: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedList$WrappedListIterator: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection$WrappedIterator
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedSet: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedSortedSet: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedSortedSet: can't find referenced class com.squareup.haha.guava.collect.AbstractMapBasedMultimap$com.squareup.haha.guava.collect.AbstractMapBasedMultimap$WrappedCollection
Warning: com.squareup.haha.guava.collect.AbstractMultimap$EntrySet: can't find referenced class com.squareup.haha.guava.collect.AbstractMultimap$com.squareup.haha.guava.collect.AbstractMultimap$Entries
Warning: com.squareup.haha.guava.collect.ImmutableMultimap$1: can't find referenced class com.squareup.haha.guava.collect.ImmutableMultimap$com.squareup.haha.guava.collect.ImmutableMultimap$Itr
Warning: com.squareup.haha.guava.collect.ImmutableMultimap$2: can't find referenced class com.squareup.haha.guava.collect.ImmutableMultimap$com.squareup.haha.guava.collect.ImmutableMultimap$Itr
Warning: com.squareup.haha.guava.collect.MapMakerInternalMap$EntryIterator: can't find referenced class com.squareup.haha.guava.collect.MapMakerInternalMap$com.squareup.haha.guava.collect.MapMakerInternalMap$HashIterator
Warning: com.squareup.haha.guava.collect.MapMakerInternalMap$HashIterator: can't find referenced class com.squareup.haha.guava.collect.MapMakerInternalMap$com.squareup.haha.guava.collect.MapMakerInternalMap$com.squareup.haha.guava.collect.MapMakerInternalMap$WriteThroughEntry
Warning: com.squareup.haha.guava.collect.MapMakerInternalMap$HashIterator: can't find referenced class com.squareup.haha.guava.collect.MapMakerInternalMap$com.squareup.haha.guava.collect.MapMakerInternalMap$com.squareup.haha.guava.collect.MapMakerInternalMap$WriteThroughEntry
Warning: com.squareup.haha.guava.collect.MapMakerInternalMap$HashIterator: can't find referenced class com.squareup.haha.guava.collect.MapMakerInternalMap$com.squareup.haha.guava.collect.MapMakerInternalMap$WriteThroughEntry
Warning: com.squareup.haha.guava.collect.MapMakerInternalMap$KeyIterator: can't find referenced class com.squareup.haha.guava.collect.MapMakerInternalMap$com.squareup.haha.guava.collect.MapMakerInternalMap$HashIterator
Warning: com.squareup.haha.guava.collect.MapMakerInternalMap$ValueIterator: can't find referenced class com.squareup.haha.guava.collect.MapMakerInternalMap$com.squareup.haha.guava.collect.MapMakerInternalMap$HashIterator
Warning: com.squareup.haha.perflib.io.MemoryMappedFileBuffer: can't find referenced class sun.misc.Cleaner
Warning: com.squareup.haha.perflib.io.MemoryMappedFileBuffer: can't find referenced class sun.nio.ch.DirectBuffer
Warning: com.squareup.haha.perflib.io.MemoryMappedFileBuffer: can't find referenced class sun.misc.Cleaner
Warning: com.squareup.haha.perflib.io.MemoryMappedFileBuffer: can't find referenced class sun.nio.ch.DirectBuffer
Warning: com.squareup.haha.trove.THashMap$EntryView: can't find referenced class com.squareup.haha.trove.THashMap$com.squareup.haha.trove.THashMap$MapBackedView
Warning: com.squareup.haha.trove.THashMap$KeyView: can't find referenced class com.squareup.haha.trove.THashMap$com.squareup.haha.trove.THashMap$MapBackedView
Warning: com.squareup.haha.trove.THashMap$ValueView: can't find referenced class com.squareup.haha.trove.THashMap$com.squareup.haha.trove.THashMap$MapBackedView
Warning: there were 50 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Exception while processing task

Even though in my proguard.cfg:

-keep class org.eclipse.mat.** { *; }
-keep class com.squareup.leakcanary.** { *; }
-keep class com.squareup.haha.** { *; }
-keep class sun.misc.** { *; }
-keep class sun.nio.** { *; }
@pyricau
Copy link
Member

pyricau commented Sep 2, 2015

mmm that's strange. What happens when you turn off proguard in your app, does LeakCanary work just fine?

@SandroMachado
Copy link

I have the same issue.
Adding the -dontwarn to the proguard file fix the issues but produces some warnings.

Proguard file:

-keep class org.eclipse.mat.** { *; }
-keep class com.squareup.leakcanary.** { *; }
-keep class com.squareup.haha.** { *; }
-dontwarn com.squareup.haha.guava.**
-dontwarn com.squareup.haha.perflib.**
-dontwarn com.squareup.haha.trove.**
-dontwarn com.squareup.leakcanary.** 

Warnings:

AGPBI: {"kind":"simple","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]}
AGPBI: {"kind":"simple","text":"(com.squareup.haha.guava.base.Joiner$1) that doesn\u0027t come with an","sources":[{}]}
AGPBI: {"kind":"simple","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]}
AGPBI: {"kind":"simple","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]}
AGPBI: {"kind":"simple","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]}
AGPBI: {"kind":"simple","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]}
AGPBI: {"kind":"simple","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]}
AGPBI: {"kind":"simple","text":"indicate that it is *not* an inner class.","sources":[{}]}
AGPBI: {"kind":"simple","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]}
AGPBI: {"kind":"simple","text":"(com.squareup.haha.guava.collect.Iterables$2) that doesn\u0027t come with an","sources":[{}]}
AGPBI: {"kind":"simple","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]}
AGPBI: {"kind":"simple","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]}
AGPBI: {"kind":"simple","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]}
AGPBI: {"kind":"simple","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]}
AGPBI: {"kind":"simple","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]}
AGPBI: {"kind":"simple","text":"indicate that it is *not* an inner class.","sources":[{}]}
AGPBI: {"kind":"simple","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]}
AGPBI: {"kind":"simple","text":"(com.squareup.haha.guava.collect.Iterables$3) that doesn\u0027t come with an","sources":[{}]}
AGPBI: {"kind":"simple","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]}
AGPBI: {"kind":"simple","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]}
AGPBI: {"kind":"simple","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]}
AGPBI: {"kind":"simple","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]}
AGPBI: {"kind":"simple","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]}
AGPBI: {"kind":"simple","text":"indicate that it is *not* an inner class.","sources":[{}]}

Probably this is unsafe.

@iNoles
Copy link

iNoles commented Sep 23, 2015

@SandroMachado Which java version you compiled on?

@SandroMachado
Copy link

@iNoles I am not compiling it, I am just importing the 1.4-SNAPSHOT using gradle.
My environment is:

Android Studio 1.3.2
Java version "1.7.0_79"

@jaydp17
Copy link

jaydp17 commented Oct 15, 2015

Same here.
Also as a side note, I do use retroLamda, if that's relevant.

@ygnessin
Copy link
Contributor

@SandroMachado's solution worked for me as well. I don't think it is unsafe, because as long as you include -keep class com.squareup.haha.** { *; } in addition to the -dontwarn lines, the classes will be preserved. I think this is the true solution and should be added to the README.

@pyricau
Copy link
Member

pyricau commented Jan 4, 2016

Should be fixed by #308

@rogerhu
Copy link
Contributor

rogerhu commented Jan 18, 2016

What do these ProGuard fixes have to do with the Marshmallow M version? I had to do the same thing in my ProGuard config as mentioned in #265 (comment)

@pyricau
Copy link
Member

pyricau commented Jan 18, 2016

@rogerhu I don't use Proguard so I have no idea if there are still issues or not. Apparently there are, see #394

@rogerhu
Copy link
Contributor

rogerhu commented Jan 19, 2016

Added here:

#398

@SandroMachado
Copy link

It is working fine here with the latest update. No problems with the current proguard consumer files included in the library. BTW, I am just using the proguard with my release configuration, enabling it on debug I get a lot of issues, not only from leakcanary but also from butterknife, etc etc

@rogerhu are you including any other proguard configuration? The latest version (1.4 beta 1) already includes the required proguard configuration file, so I don't need to add any other special rule at least with it enable only for the release configuration.

@rogerhu
Copy link
Contributor

rogerhu commented Jan 19, 2016

rechecking...i noticed leak canary actually wasn't working for me until i brought these proguard lines in...but on a new project leakcanary works fine. trying to figure out what's different

@rogerhu
Copy link
Contributor

rogerhu commented Jan 20, 2016

The problem happens for debug builds, not for release builds because release compiles are using com.squareup.leakcanary:leakcanary-android-no-op:1.4-SNAPSHOT.

Change your relaseCompile dependency and you will see the same problem:

dependencies {
    releaseCompile 'com.squareup.leakcanary:leakcanary-android:1.4-SNAPSHOT'
}

I've updated the PR for consumer-proguard-rules.pro to ensure that the library includes these definitions by default.

@Zeliret
Copy link

Zeliret commented Mar 10, 2016

Well. Same for me. Everything was fine. I don't know why this error occurs...
I'm using retro lambda & proguard. Today I suddenly got this error :(

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.

@WonderCsabo
Copy link

I am also seeing these warnings. There are started happening when i updated to 2.0.0-beta7 version of the Android Gradle Plugin. The warnings are shown when the transformClassesWithDexFor{Variant} task is running.

@pyricau
Copy link
Member

pyricau commented Apr 1, 2016

Help welcome!

We use jarjar & Proguard to embed perflib into LeakCanary. perflib depends on Guava, so Proguard allows us to shrink it down to the bare minimum. I think Proguard is a bit too agressive and removes inner classes attributes that later makes it unhappy when integrating into another app. Proguard is weird.

@rogerhu
Copy link
Contributor

rogerhu commented Apr 1, 2016

The warnings are there but they are not fatal. The Proguard rules set not to error on them (https://github.com/square/leakcanary/blob/master/leakcanary-android/consumer-proguard-rules.pro)

I don't think this is a blocking issue. And it should probably be opened as a separate issue.

@WonderCsabo
Copy link

@pyricau i am starting to think this is a ProGuard issue. I added more ProGuard rules to preserve the EnclosingMethod attribute. However when examining the ProGuarded class (javap -v Joiner$1.class), it seems the attribute is still removed. 😢

@WonderCsabo
Copy link

After reading further, -keepattributes should not be needed when not obfuscating (the manual says -keepattributes is only applicable when obfuscating. i guess because attributes are not stripped when not obfuscating). I opened a topic in ProGuard forum for clarification.

@MichaelEvans
Copy link

I'm running into these warnings without using Proguard. Are there any fixes to silence these for non-proguard users?

@WonderCsabo
Copy link

The core problem was fixed. in haha. But to propagate the fix to LeakCanary, a new version of haha must be pushed, and the dependency on haha in LeakCanary must be modified to the new version. @pyricau when do you plan to do this?

@pyricau
Copy link
Member

pyricau commented Apr 12, 2016

when I or @jrodbx can get to it. Sorry, I can't provide any estimate, we have a tight deadline at work.

@WonderCsabo
Copy link

@pyricau fair enough, thanks for the great library anyway!

@PaulWoitaschek
Copy link
Contributor

My build was also just breaking without me using proguard. It worked fine for some time.

@matpag
Copy link
Contributor

matpag commented May 4, 2016

Waiting for the release ;)

Thank you guys

@WonderCsabo
Copy link

@jrodbx updated the haha dependency, so this is now fixed. It is available in the Sonatype Snapshot repo using leakcanary version 1.4-SNAPSHOT. Thanks guys!

@jrodbx
Copy link
Collaborator

jrodbx commented May 24, 2016

oops, forgot to update this here. Thanks for taking point, @WonderCsabo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests