Leakcanary: Unable to get provider leakcanary.internal.AppWatcherInstaller

Created on 8 Nov 2019  路  9Comments  路  Source: square/leakcanary

Description

Hi!

Scenario:
I'm building an instant app through app bundle. At the time of launching the instant app I get a runtime exception.
There is a way to disable leak canary when is instant app?

StackTrace:

java.lang.RuntimeException: Unable to get provider leakcanary.internal.AppWatcherInstaller: kotlin.KotlinNullPointerException
        at android.app.ActivityThread.installProvider(ActivityThread.java:6988)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445)
        at android.app.ActivityThread.access$1300(ActivityThread.java:219)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: kotlin.KotlinNullPointerException
        at leakcanary.internal.InternalLeakCanary.addDynamicShortcut(InternalLeakCanary.kt:124)
        at leakcanary.internal.InternalLeakCanary.invoke(InternalLeakCanary.kt:83)
        at leakcanary.internal.InternalLeakCanary.invoke(InternalLeakCanary.kt:30)
        at leakcanary.internal.InternalAppWatcher.install(InternalAppWatcher.kt:70)
        at leakcanary.internal.AppWatcherInstaller.onCreate(AppWatcherInstaller.kt:19)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:2092)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:2066)
        at android.app.ActivityThread.installProvider(ActivityThread.java:6983)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)聽
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445)聽
        at android.app.ActivityThread.access$1300(ActivityThread.java:219)聽
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)聽
        at android.os.Handler.dispatchMessage(Handler.java:107)聽
        at android.os.Looper.loop(Looper.java:214)聽
        at android.app.ActivityThread.main(ActivityThread.java:7356)聽
        at java.lang.reflect.Method.invoke(Native Method)聽
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)聽
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)聽

Steps to Reproduce

From an instant enabled dynamic feature:

  1. Add leak canary dependency to gradle
  2. Run instant app feature

Expected behavior:
Instant app should run normally without crashing at launch time.

Version Information

  • LeakCanary version: 2.0-beta-3
  • Android OS version: 10
  • Gradle version: 5.6.4

Additional Information

As I could investigate, the problem is here https://github.com/square/leakcanary/blob/53fa1902d3eb3aec9d99257a517dc6ad198acc39/leakcanary-android-core/src/main/java/leakcanary/internal/InternalLeakCanary.kt#L124
Looks like in instant app the ShortcutManager service is not available.

bug

Most helpful comment

Hi! Thank you all for that quick response!
I had the chance to test the latest snapshot and I can confirm it's working! 馃帀

All 9 comments

馃檹Thank you for opening an issue! LeakCanary is maintained by volunteers from the community. Please be kind and remember that LeakCanary isn't anyone's main job 馃槝.

I made a PR with fix, but I don't have Instant Apps environment set up at the moment, so can't verify it 馃槃
Also, there's no guarantee something else won't start breaking now. We really need to test Instant App case.
@SmasSive if you have a chance and can check out my branch to verify the fix, that would help a lot! 馃檶

@SmasSive Can you test with the latest Snapshot version? https://square.github.io/leakcanary/faq/#how-do-i-use-the-snapshot-version

Hi! Thank you all for that quick response!
I had the chance to test the latest snapshot and I can confirm it's working! 馃帀

@SmasSive thanks for verifying it!
If you notice any other issues with Instant Apps - please let us know.
By the way, does leak Canary create a launcher icon for its activity when used from instant app?

@Armaxis no, the leak canary's launcher icon is not created.
Do not hesitate to ask me about leak canary features in instant apps, I'll be glad to help!

I'm still receiving this crash for both 2.0, 2.1 leakcanary version. Using tablet with 8.0 and 8.1. App is not instant, no support libs in project.

java.lang.RuntimeException: Unable to get provider leakcanary.internal.AppWatcherInstaller$MainProcess: kotlin.KotlinNullPointerException
        at android.app.ActivityThread.installProvider(ActivityThread.java:6304)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5867)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5788)
        at android.app.ActivityThread.-wrap1(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1664)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6600)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:772)
     Caused by: kotlin.KotlinNullPointerException
        at leakcanary.internal.InternalLeakCanary.addDynamicShortcut(InternalLeakCanary.kt:127)
        at leakcanary.internal.InternalLeakCanary.invoke(InternalLeakCanary.kt:98)
        at leakcanary.internal.InternalLeakCanary.invoke(InternalLeakCanary.kt:29)
        at leakcanary.internal.InternalAppWatcher.install(InternalAppWatcher.kt:71)
        at leakcanary.internal.AppWatcherInstaller.onCreate(AppWatcherInstaller.kt:35)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1921)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1896)
        at android.app.ActivityThread.installProvider(ActivityThread.java:6301)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5867)聽
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5788)聽
        at android.app.ActivityThread.-wrap1(Unknown Source:0)聽
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1664)聽
        at android.os.Handler.dispatchMessage(Handler.java:105)聽
        at android.os.Looper.loop(Looper.java:164)聽
        at android.app.ActivityThread.main(ActivityThread.java:6600)聽
        at java.lang.reflect.Method.invoke(Native Method)聽
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)聽
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:772)聽

@Scyter based on line numbers this look like the stracktrace in from 2.0. Can you repro with 2.1 and share the stacktrace from it?

@pyricau , I've find out problem. It was Linux kernel issue. At least for now it looks so.

Was this page helpful?
0 / 5 - 0 ratings