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

AssertionError crash on startup in PlumberInstaller #1899

Closed
dbrant opened this issue Jul 30, 2020 · 6 comments
Closed

AssertionError crash on startup in PlumberInstaller #1899

dbrant opened this issue Jul 30, 2020 · 6 comments

Comments

@dbrant
Copy link

dbrant commented Jul 30, 2020

I'm seeing a crash upon startup, which seems to be internal to the plumber component:

java.lang.AssertionError: impossible
        at java.lang.Enum$1.create(Enum.java:269)
        at java.lang.Enum$1.create(Enum.java:260)
        at libcore.util.BasicLruCache.get(BasicLruCache.java:58)
        at java.lang.Enum.getSharedConstants(Enum.java:286)
        at java.lang.Class.getEnumConstantsShared(Class.java:2291)
        at java.lang.JavaLangAccess.getEnumConstantsShared(JavaLangAccess.java:40)
        at java.util.EnumSet.getUniverse(EnumSet.java:389)
        at java.util.EnumSet.noneOf(EnumSet.java:107)
        at java.util.EnumSet.allOf(EnumSet.java:126)
        at leakcanary.AndroidLeakFixes$Companion.applyFixes$default(AndroidLeakFixes.kt:1)
        at leakcanary.internal.PlumberInstaller.onCreate(PlumberInstaller.kt:2)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1751)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1726)
        at android.app.ActivityThread.installProvider(ActivityThread.java:5811)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5403)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5342)
        at android.app.ActivityThread.-wrap2(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6077)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
     Caused by: java.lang.NoSuchMethodException: values []
        at java.lang.Class.getMethod(Class.java:1981)
        at java.lang.Class.getDeclaredMethod(Class.java:1960)
        at java.lang.Enum$1.create(Enum.java:265)
        at java.lang.Enum$1.create(Enum.java:260) 
        at libcore.util.BasicLruCache.get(BasicLruCache.java:58) 
        at java.lang.Enum.getSharedConstants(Enum.java:286) 
        at java.lang.Class.getEnumConstantsShared(Class.java:2291) 
        at java.lang.JavaLangAccess.getEnumConstantsShared(JavaLangAccess.java:40) 
        at java.util.EnumSet.getUniverse(EnumSet.java:389) 
        at java.util.EnumSet.noneOf(EnumSet.java:107) 
        at java.util.EnumSet.allOf(EnumSet.java:126) 
        at leakcanary.AndroidLeakFixes$Companion.applyFixes$default(AndroidLeakFixes.kt:1) 
        at leakcanary.internal.PlumberInstaller.onCreate(PlumberInstaller.kt:2) 
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1751) 
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1726) 
        at android.app.ActivityThread.installProvider(ActivityThread.java:5811) 
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5403) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5342) 
        at android.app.ActivityThread.-wrap2(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6077) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) 

I was able to resolve it by including the following in my ProGuard rules:

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

Is it known that these rules are required, or am I doing something wrong myself?

Version Information

  • LeakCanary version: 2.4
  • Android OS version: tested on API 24 and 29
  • Gradle version: 4.0.1
pyricau added a commit that referenced this issue Aug 31, 2020
@pyricau
Copy link
Member

pyricau commented Aug 31, 2020

Thanks for the bug report and suggested fix! Definitely not a known issue.

I haven't been able to repro, can you share a sample project or specific about the proguard config that make this happen?

Alternatively, can you try with this more specific configuration and confirm it still works:

# https://www.guardsquare.com/en/products/proguard/manual/examples#enumerations
-keep public enum leakcanary.AndroidLeakFixes {
  public static **[] values();
  public static ** valueOf(java.lang.String);
}

I've added that to https://github.com/square/leakcanary/pull/1914/files

The reason I want the more specific configuration is because apps using proguard probably still want to shrink most of their enums.

@dbrant
Copy link
Author

dbrant commented Sep 9, 2020

Well this is odd, I can't repro this behavior now either, even on the exact commit where I observed it before. I suppose this can now be closed, and we can revisit if it's observed again.

BTW we've been using LeakCanary in the official Wikipedia app, and have found it immensely useful. Thanks!

@dbrant dbrant closed this as completed Sep 9, 2020
@pyricau
Copy link
Member

pyricau commented Sep 12, 2020

Thx! Feel free to reopen or open a new one if this happens again.

I'm glad it's useful! We have the guest book for testimonials ;)

@cooltey
Copy link

cooltey commented Oct 13, 2020

Seen this issue today and resolved it by restarting PC, invalidating Android Studio cached and checking out commits back and forth.

@jacob-peterson-zz
Copy link

I also ran into this issue after adding Plumber to release builds of my app. Others on my team could reproduce it as well but I was unable to repro it in a sample app with a similar configuration.

  • LeakCanary version: 2.6
  • Gradle version: 4.1.1

@jzbrooks
Copy link
Contributor

jzbrooks commented Jan 4, 2021

Here's a sample project that reproduces the issue. The linked PR would appropriately address the issue.

leakcanaryr8.zip

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

Successfully merging a pull request may close this issue.

5 participants