androidgradleleakcanary

Android leakcanary obfuscate


Confusion can't use leakcanary LeakCanary plugin has been imported java.lang.NullPointerException

have integrated Leakcanary for the first time in my app, The trace is generated like the following. Can someone explain to me what does it mean?

  2022-03-05 13:08:12.684 25896-25896/com.liangke.tingXieBen E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.liangke.tingXieBen, PID: 25896
    java.lang.NullPointerException
        at curtains.internal.WindowCallbackWrapper$Companion.getJetpackWrapped(:112)
        at curtains.internal.WindowCallbackWrapper$Companion.unwrap(:154)
        at curtains.WindowsKt.getWrappedCallback(:233)
        at leakcanary.RootViewWatcher$listener$1.onRootViewAdded(:46)
        at curtains.OnRootViewAddedListener$DefaultImpls.onRootViewsChanged(:38)
        at leakcanary.RootViewWatcher$listener$1.onRootViewsChanged(:43)
        at curtains.internal.RootViewsSpy$delegatingViewList$1.add(:25)
        at curtains.internal.RootViewsSpy$delegatingViewList$1.add(:23)
        at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:403)
        at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:109)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4535)
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)




  debug {
        minifyEnabled true //注意测试的时候不要混淆
      //  testCoverageEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguardTest-rules.pro'
    }

enter link description here


Solution

  • I got the same crash log because I enabled:

    minifyEnabled
    

    in debug mode. The solution is adding:

    -keep class androidx.appcompat.view.WindowCallbackWrapper { *; }
    -keep class android.support.v7.view.WindowCallbackWrapper { *; }
    

    in your progurd rules.