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

Unable to get provider leakcanary.internal.LeakCanaryFileProvider #1597

Closed
CaiJinFu opened this issue Sep 26, 2019 · 34 comments
Closed

Unable to get provider leakcanary.internal.LeakCanaryFileProvider #1597

CaiJinFu opened this issue Sep 26, 2019 · 34 comments

Comments

@CaiJinFu
Copy link

CaiJinFu commented Sep 26, 2019

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

@Armaxis
Copy link
Member

Armaxis commented Oct 4, 2019

Hello!
It looks like the LeakCanaryFileProvider is not present in the final apk, while being present in the AndroidManifest.xml as a content provider (this is done my leakcanary, it's correct).

With the LeakCanaryFileProvider being a part of -core package it's quite surprising it didn't made its way to the apk. Are you using code shrinker on the debug builds?

Also, can you please share the part of gradle script where you add dependency on Leakcanary? Just want to make sure it's been set up properly.

@CaiJinFu
Copy link
Author

CaiJinFu commented Oct 8, 2019

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

@Armaxis
Copy link
Member

Armaxis commented Oct 8, 2019

Dependency looks correct.
Does the issue remain if you try using 2.0-beta-2 version of the lib?

@CaiJinFu
Copy link
Author

CaiJinFu commented Oct 10, 2019

yes,I still have problems with this version 2.0-beta-2. I guess if I used Alibaba's hotfix.I have 2 Applications.This is my wrong log.SophixStubApplication is the application of hotfix.There is also a my own application.

java.lang.RuntimeException: Unable to create application com.xincaidong.truemerger.base.SophixStubApplication: java.lang.RuntimeException: abandon initialization: installProviders
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5959)
        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.RuntimeException: abandon initialization: installProviders
        at com.taobao.sophix.a.c.a(Sophix:739)
        at com.taobao.sophix.a.c.p(Sophix:671)
        at com.taobao.sophix.a.c.b(Sophix:683)
        at com.taobao.sophix.a.e.a(Sophix:203)
        at com.taobao.sophix.SophixApplication.onCreate(Sophix:16)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1155)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5954)
        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.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.taobao.sophix.a.c.p(Sophix:668)
        at com.taobao.sophix.a.c.b(Sophix:683) 
        at com.taobao.sophix.a.e.a(Sophix:203) 
        at com.taobao.sophix.SophixApplication.onCreate(Sophix:16) 
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1155) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5954) 
        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.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-ji2WskANWPbI6eXML9bS5g==/base.apk"],nativeLibraryDirectories=[/data/app/com.xincaidong.truemerger-ji2WskANWPbI6eXML9bS5g==/lib/arm64, /data/app/com.xincaidong.truemerger-ji2WskANWPbI6eXML9bS5g==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]

@forJrking
Copy link

me too

@meablelee2013
Copy link

meablelee2013 commented Oct 22, 2019

I meet the same issue.
do not debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-3' the application is ok,but do it,even if add -keep class leakcanary.internal.LeakCanaryFileProvider
to multidex-config.pro,it still show the this error.

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.xxx.xxx-f10Ws5s164V4y_DNWZgsQw==/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxx-f10Ws5s164V4y_DNWZgsQw==/lib/arm64, /data/app/com.xxx.xxx-f10Ws5s164V4y_DNWZgsQw==/base.apk!/lib/arm64-v8a, /system/lib64]]
        at android.app.ActivityThread.installProvider(ActivityThread.java:6452)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5994)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5900)
        at android.app.ActivityThread.access$1100(ActivityThread.java:202)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1665)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:198)
        at android.app.ActivityThread.main(ActivityThread.java:6729)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "leakcanary.internal.LeakCanaryFileProvider" on path: DexPathList[[zip file "/data/app/com.xxx.xxx-f10Ws5s164V4y_DNWZgsQw==/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxx-f10Ws5s164V4y_DNWZgsQw==/lib/arm64, /data/app/com.xxx.xxx-f10Ws5s164V4y_DNWZgsQw==/base.apk!/lib/arm64-v8a, /system/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        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:62)
        at android.app.ActivityThread.installProvider(ActivityThread.java:6436)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5994) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5900) 
        at android.app.ActivityThread.access$1100(ActivityThread.java:202) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1665) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:198) 
        at android.app.ActivityThread.main(ActivityThread.java:6729) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 

@mikilangkilo
Copy link

me too,i also use

-keep class leakcanary.** {*;}

in proguard and multidex-config

still not work

and in output.apk i can find the provider registered in AndroidManifest.xml.

and no problem happened to other provider

@afinal
Copy link

afinal commented Oct 29, 2019

I have this problem too

@pyricau
Copy link
Member

pyricau commented Oct 29, 2019

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.

@square square deleted a comment from XiFanYin Nov 9, 2019
@square square deleted a comment from XiFanYin Nov 9, 2019
@square square deleted a comment from CaiJinFu Nov 9, 2019
@pyricau
Copy link
Member

pyricau commented Nov 9, 2019

Note: I will delete "me too" comments as well as comments that aren't in English.

@zhuruyi2013
Copy link

i meet this problem too.
And I decompile the apk to see leakcanary core code,but only has a R.java.
my project define flavor,and i compile use “devDebug” build variant.

this is my import code :
debugCompile compileDependencies.leakCanaryDebug
my gradle version is too below, 3.3.

i think reason of this problem may be Depend on the isolation.
api or implemention?

@Armaxis
Copy link
Member

Armaxis commented Nov 11, 2019

@zhuruyi2013 try using debugImplementation instead of debugCompile. Let us know if that helps.

@pyricau
Copy link
Member

pyricau commented Nov 13, 2019

I don't see howdebugCompile or debugImplementation can make a difference, looks like a class is missing. We need a sample project to investigate this further, and if none can be provided then I'll close this issue.

@shumidub
Copy link

shumidub commented Nov 18, 2019

I have simmilar error (Unable to get provider leakcanary.internal.AppWatcherInstaller: java.lang.ClassNotFoundException: Didn't find class "leakcanary.internal.AppWatcherInstaller) :

Fatal Exception: java.lang.RuntimeException: Unable to get provider leakcanary.internal.AppWatcherInstaller: java.lang.ClassNotFoundException: Didn't find class "leakcanary.internal.AppWatcherInstaller" on path: DexPathList[[zip file "/data/app/com.tradingview.tradingviewapp-HSrgA6AQJPZdqvhQVPC8Gw==/base.apk"],nativeLibraryDirectories=[/data/app/com.tradingview.tradingviewapp-HSrgA6AQJPZdqvhQVPC8Gw==/lib/arm, /system/lib, /vendor/lib]]
       at android.app.ActivityThread.installProvider(ActivityThread.java:6284)
       at android.app.ActivityThread.installContentProviders(ActivityThread.java:5847)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5764)
       at android.app.ActivityThread.-wrap1(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1691)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6549)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:451)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:888)

It is not reproduce stable. Only some users from thousand of users have this error. I use R8, and split apk.
My dependencies looks like

    implementation "com.squareup.leakcanary:leakcanary-object-watcher-android:2.0-beta-3"
    debugImplementation "com.squareup.leakcanary:leakcanary-android:2.0-beta-3"

My proguard rules include this:

-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.** { *; }
-dontwarn android.app.Notification

@pyricau
Copy link
Member

pyricau commented Nov 18, 2019

Can you provide a project that we can use to reproduce this issue?

Note that your proguard rules are not correct anymore (these are for leakcanary 1.0) but this should be ok because the new version has its proguard rules included.

@shumidub
Copy link

shumidub commented Nov 19, 2019

I can not provide the project, because it is my company production app. And I can not reproduce this issue. It happends only with little count of users .

@pyricau
Copy link
Member

pyricau commented Nov 19, 2019

"It happends only with little count of users" => Are you using the object watcher in production? If you have no need for it you can set it as a debug dependency (which should be the default when you add leakcanary) and that way it won't ship in production.

@shumidub
Copy link

shumidub commented Nov 20, 2019

"It happends only with little count of users" => Are you using the object watcher in production? If you have no need for it you can set it as a debug dependency (which should be the default when you add leakcanary) and that way it won't ship in production.

I use dependencies:

implementation "com.squareup.leakcanary:leakcanary-object-watcher-android:2.0-beta-3" 
debugImplementation "com.squareup.leakcanary:leakcanary-android:2.0-beta-3"

If I remove implementation "com.squareup.leakcanary:leakcanary-object-watcher-android:2.0-beta-3" I get compilation error, because something should be imported for non debug build type

@Armaxis
Copy link
Member

Armaxis commented Nov 21, 2019

If I remove implementation "com.squareup.leakcanary:leakcanary-object-watcher-android:2.0-beta-3" I get compilation error, because something should be imported for non debug build type

Can you share the error message you get? LeakCanary is intended to be debug-only dependency; this might be the reason why you get the crashes.

@shumidub
Copy link

shumidub commented Nov 22, 2019

I have

import leakcanary.AppWatcher

interface ReferenceWatcher {
    fun watch(watchedObject: Any)

    object DISABLED : ReferenceWatcher {
        override fun watch(watchedObject: Any) {}
    }

    object ENABLED : ReferenceWatcher {
        override fun watch(watchedObject: Any) {
            AppWatcher.objectWatcher.watch(watchedObject)
        }
    }
}

and use It as

if (BuildConfig.DEBUG) {
            ReferenceWatcherProvider.setInstance(ReferenceWatcher.ENABLED)
}

If I remove implementation "com.squareup.leakcanary:leakcanary-object-watcher-android:2.0-beta-3" I get compilation error "ReferenceWatcher.kt: (14, 13): Unresolved reference: AppWatcher"

Of course I can provide different ReferenceWatcher for each build types, but we have 10 build variant and it is not usefull to write this for each of them

@Armaxis
Copy link
Member

Armaxis commented Nov 22, 2019

As an alternative you can use reflection to set these, by checking first that the class is available at the runtime. It's more boilerplate, but will work if you can't extract code to some debug-only folder.

@pyricau
Copy link
Member

pyricau commented Nov 22, 2019

leakcanary-object-watcher-android is meant to be used in production, that's actually ok, though if the content provider class isn't available for a number of users then I have no idea what could cause this.

@devism
Copy link

devism commented Dec 6, 2019

I think I'm getting the same issue.

12-05 20:17:29.651 15083-15083/? I/art: Late-enabling -Xcheck:jni
    Late-enabling JIT
12-05 20:17:29.682 15083-15083/? I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000
12-05 20:17:29.746 15083-15083/com.app.tablesign W/System: ClassLoader referenced unknown path: /data/app/com.app.tablesign-1/lib/arm
12-05 20:17:29.794 15083-15083/com.app.tablesign D/LeakCanary: Installing AppWatcher
12-05 20:17:29.803 15083-15083/com.app.tablesign I/art: Rejecting re-init on previously-failed class java.lang.Class<leakcanary.internal.AndroidSupportFragmentDestroyWatcher$fragmentLifecycleCallbacks$1>
    Rejecting re-init on previously-failed class java.lang.Class<leakcanary.internal.AndroidSupportFragmentDestroyWatcher$fragmentLifecycleCallbacks$1>
12-05 20:17:29.807 15083-15083/com.app.tablesign I/art: Rejecting re-init on previously-failed class java.lang.Class<leakcanary.internal.AndroidSupportFragmentDestroyWatcher$fragmentLifecycleCallbacks$1>
    Rejecting re-init on previously-failed class java.lang.Class<leakcanary.internal.AndroidSupportFragmentDestroyWatcher$fragmentLifecycleCallbacks$1>
12-05 20:17:29.808 15083-15083/com.app.tablesign I/art: Rejecting re-init on previously-failed class java.lang.Class<leakcanary.internal.AndroidSupportFragmentDestroyWatcher$fragmentLifecycleCallbacks$1>
12-05 20:17:29.809 15083-15083/com.app.tablesign D/AndroidRuntime: Shutting down VM
12-05 20:17:29.811 15083-15083/com.app.tablesign E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.app.tablesign, PID: 15083
    java.lang.RuntimeException: Unable to get provider leakcanary.internal.AppWatcherInstaller$MainProcess: java.lang.reflect.InvocationTargetException
        at android.app.ActivityThread.installProvider(ActivityThread.java:5156)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
        at android.app.ActivityThread.-wrap1(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:742)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632)
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at leakcanary.internal.FragmentDestroyWatcher.getWatcherIfAvailable(FragmentDestroyWatcher.kt:99)
        at leakcanary.internal.FragmentDestroyWatcher.install(FragmentDestroyWatcher.kt:62)
        at leakcanary.internal.InternalAppWatcher.install(InternalAppWatcher.kt:70)
        at leakcanary.internal.AppWatcherInstaller.onCreate(AppWatcherInstaller.kt:35)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
        at android.app.ActivityThread.installProvider(ActivityThread.java:5153)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688) 
        at android.app.ActivityThread.-wrap1(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5417) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:742) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632) 
     Caused by: java.lang.NoClassDefFoundError: leakcanary.internal.AndroidSupportFragmentDestroyWatcher$fragmentLifecycleCallbacks$1
        at leakcanary.internal.AndroidSupportFragmentDestroyWatcher.<init>(AndroidSupportFragmentDestroyWatcher.kt:30)
        at java.lang.reflect.Constructor.newInstance(Native Method) 
        at leakcanary.internal.FragmentDestroyWatcher.getWatcherIfAvailable(FragmentDestroyWatcher.kt:99) 
        at leakcanary.internal.FragmentDestroyWatcher.install(FragmentDestroyWatcher.kt:62) 
        at leakcanary.internal.InternalAppWatcher.install(InternalAppWatcher.kt:70) 
        at leakcanary.internal.AppWatcherInstaller.onCreate(AppWatcherInstaller.kt:35) 
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1748) 
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1723) 
        at android.app.ActivityThread.installProvider(ActivityThread.java:5153) 
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688) 
        at android.app.ActivityThread.-wrap1(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5417) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:742) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632) 
12-05 20:17:31.982 15083-15083/com.app.tablesign I/Process: Sending signal. PID: 15083 SIG: 9

@pyricau
Copy link
Member

pyricau commented Dec 6, 2019

@devism this is a different issue. Do you have a sample project that reproduces it? If yes can you create a new issue?

@devism
Copy link

devism commented Dec 6, 2019

I do have a sample project that reproduces the issue. I will create a new issue.

@pyricau
Copy link
Member

pyricau commented Dec 10, 2019

Note to readers: @devism moved their issue to #1662

Everyone else here: which version of the support library (or Android X) are you using?

Can you provide a sample project or an APK that reproduces this consistently?

@pyricau
Copy link
Member

pyricau commented Dec 18, 2019

Summary of everything that's been reported in this issue:

  • @CaiJingFu, @meablelee2013 have a crash because the LeakCanaryFileProvider class is not found. We know they use Android X. We don't know which versions of Android this is crashing on. The crash is 100% reproducible. Seems similar to this Stack Overflow question (not solved). Android X ships its own AppComponentFactory (added here to provide different component impls per version) which is now in charge of creating provider instances. @CaiJingFu mentioned a "hotfix" from Alibaba, I have no idea what that means but apparently that involves having two application classes, one of which is a stub. I wonder what that's about.

Without a sample project to reproduce, it's hard to figure it out. This could be a multidex issue if the Provider class somehow doesn't end up in the main dex.

  • @GWYloved wrote they have the same crash, and they mention a provider but did not provide a stacktrace. They do mention multidex, but we don't know if they use AndroidX. We also don't know which version of Android this is running on.

  • @forJrking @afinal wrote me too but did not provide any details, so it could be a totally different issue.

  • @shumidub has a different error: AppWatcherInstaller cannot be found. They mentioned it doesn't happen systematically, it happens in production for a low number of users. They have a release dependency on the leakcanary-object-watcher-android dependency (which is ok). The app is https://play.google.com/store/apps/details?id=com.tradingview.tradingviewapp . We don't know if this is happening on a specific subset of Android versions or not, a specific manufacturer and we don't know if they've upgraded to Android X or not. The stacktrace doesn't show AppComponentFactory.instantiateProvider so seems different from the original error. This really looks like custom Android builds not loading providers correctly.

  • @devism had a similar "Unable to get provider" issue except it was a different cause (classloading issue with really old support library) which has been fixed for a future release.

@JackFung2015
Copy link

I solved this problem by use "debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-alpha-1'"

@pyricau
Copy link
Member

pyricau commented Jan 7, 2020

@JackFung2015 There were several distinct problems described here, which one did you solve? Also you should update to 2.1 :)

@JackFung2015
Copy link

@JackFung2015 There were several distinct problems described here, which one did you solve? Also you should update to 2.1 :)

Using version 2.1 will cause the program to crash directly

@pyricau
Copy link
Member

pyricau commented Jan 13, 2020

@JackFung2015 if it's a runtime crash of the app then you should have a stacktrace. Can you share that stacktrace?

@gustavofc1997
Copy link

gustavofc1997 commented Jan 22, 2020

currently i am getting this error
java.lang.RuntimeException: Unable to get provider leakcanary.internal.AppWatcherInstaller$MainProcess: android.content.res.Resources$NotFoundException: Resource ID #0x7f040004
looks like similar but in this case cannot find a resource , any idea guys?
and i found this message
Resource 7f040004 is a complex map type. E/InstrumentationResultPrinter: Failed to mark test No Tests as finished after process crash E/MonitoringInstr: Exception encountered by: null. Dumping thread state to outputs and pining for the fjords.

@pyricau
Copy link
Member

pyricau commented Jan 24, 2020

@gustavofc1997 please file a separate issue and provide the full stacktrace.

@pyricau
Copy link
Member

pyricau commented Feb 5, 2020

I'm going to close this for now, and lock comments. If you can reproduce this with a sample project then please open a new issue and provide the sample project.

@pyricau pyricau closed this as completed Feb 5, 2020
@square square locked as off-topic and limited conversation to collaborators Feb 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests