Android leakcanary 混淆
Android leakcanary obfuscate
混淆不能使用leakcanary
LeakCanary 插件已导入
java.lang.NullPointerException
第一次在我的应用中集成Leakcanary,生成的trace如下。谁能给我解释一下这是什么意思?
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.onRootViewAdded(:46)
at curtains.OnRootViewAddedListener$DefaultImpls.onRootViewsChanged(:38)
at leakcanary.RootViewWatcher$listener.onRootViewsChanged(:43)
at curtains.internal.RootViewsSpy$delegatingViewList.add(:25)
at curtains.internal.RootViewsSpy$delegatingViewList.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'
}
我得到了相同的崩溃日志,因为我启用了:
minifyEnabled
处于调试模式。解决方案是添加:
-keep class androidx.appcompat.view.WindowCallbackWrapper { *; }
-keep class android.support.v7.view.WindowCallbackWrapper { *; }
在您的 progurd 规则中。
混淆不能使用leakcanary LeakCanary 插件已导入 java.lang.NullPointerException
第一次在我的应用中集成Leakcanary,生成的trace如下。谁能给我解释一下这是什么意思?
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.onRootViewAdded(:46)
at curtains.OnRootViewAddedListener$DefaultImpls.onRootViewsChanged(:38)
at leakcanary.RootViewWatcher$listener.onRootViewsChanged(:43)
at curtains.internal.RootViewsSpy$delegatingViewList.add(:25)
at curtains.internal.RootViewsSpy$delegatingViewList.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'
}
我得到了相同的崩溃日志,因为我启用了:
minifyEnabled
处于调试模式。解决方案是添加:
-keep class androidx.appcompat.view.WindowCallbackWrapper { *; }
-keep class android.support.v7.view.WindowCallbackWrapper { *; }
在您的 progurd 规则中。