leakcanary: Unable to get provider leakcanary.internal.LeakCanaryFileProvider

Error message:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.xincaidong.truemerger, PID: 29219
    java.lang.RuntimeException: Unable to get provider leakcanary.internal.LeakCanaryFileProvider: java.lang.ClassNotFoundException: Didn't find class "leakcanary.internal.LeakCanaryFileProvider" on path: DexPathList[[zip file "/data/app/com.xincaidong.truemerger-dH6uDnSLWeCztjnKidrcTA==/base.apk"],nativeLibraryDirectories=[/data/app/com.xincaidong.truemerger-dH6uDnSLWeCztjnKidrcTA==/lib/arm64, /data/app/com.xincaidong.truemerger-dH6uDnSLWeCztjnKidrcTA==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
        at android.app.ActivityThread.installProvider(ActivityThread.java:6542)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:6030)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5936)
        at android.app.ActivityThread.access$1200(ActivityThread.java:200)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1673)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:201)
        at android.app.ActivityThread.main(ActivityThread.java:6815)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "leakcanary.internal.LeakCanaryFileProvider" on path: DexPathList[[zip file "/data/app/com.xincaidong.truemerger-dH6uDnSLWeCztjnKidrcTA==/base.apk"],nativeLibraryDirectories=[/data/app/com.xincaidong.truemerger-dH6uDnSLWeCztjnKidrcTA==/lib/arm64, /data/app/com.xincaidong.truemerger-dH6uDnSLWeCztjnKidrcTA==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:171)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.app.AppComponentFactory.instantiateProvider(AppComponentFactory.java:121)
        at androidx.core.app.CoreComponentFactory.instantiateProvider(CoreComponentFactory.java:60)
        at android.app.ActivityThread.installProvider(ActivityThread.java:6526)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:6030) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5936) 
        at android.app.ActivityThread.access$1200(ActivityThread.java:200) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1673) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:201) 
        at android.app.ActivityThread.main(ActivityThread.java:6815) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873) 

Dependency:

debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-3'

不集成的时候,都是可以运行的,一集成之后就跑不了。项目是使用了AndroidX的,语言是java

Edit with translation from Google translate:

When it is not integrated, it can be run, and it cannot run after integration. The project uses AndroidX and the language is java

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 34 (18 by maintainers)

Most upvoted comments

Please refrain from adding “me too” comments that don’t provide any insights, and use 👍 reactions instead.

Questions for those having the issue:

  • do you use proguard? Anyone having this issue and not using proguard?
  • can you provide a sample project that reproduces the issue?
  • can you provide an APK that reproduces the issue?
  • Is the LeakCanaryFileProvider class included into the dex files of your APK? If yes, is it in the main dex or secondary dexes?
  • does anyone have this problem in a single dex app?

We should definitely add the provider to our proguard rules, same as the installer. Though I’m not sure if that’s the root cause here.

This is my dependence debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-3'