haroldadmin / WhatTheStack

See a pretty error screen when your Android app crashes
Apache License 2.0
245 stars 22 forks source link

Add ProGuard rules to keep WhatTheStackInitializer #7

Closed msfjarvis closed 4 years ago

msfjarvis commented 4 years ago

Without this my app consistently crashes due to the class being discarded by R8.

Stacktrace ``` D Shutting down VM E FATAL EXCEPTION: main E Process: dev.msfjarvis.aps, PID: 2800 E java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: java.lang.ClassNotFoundException: com .haroldadmin.whatthestack.WhatTheStackInitializer E at android.app.ActivityThread.installProvider(ActivityThread.java:7135) E at android.app.ActivityThread.installContentProviders(ActivityThread.java:6675) E at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6592) E at android.app.ActivityThread.access$1300(ActivityThread.java:233) E at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1896) E at android.os.Handler.dispatchMessage(Handler.java:106) E at android.os.Looper.loop(Looper.java:223) E at android.app.ActivityThread.main(ActivityThread.java:7523) E at java.lang.reflect.Method.invoke(Native Method) E at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) E at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941) E Caused by: androidx.startup.StartupException: java.lang.ClassNotFoundException: com.haroldadmin.whatthestack.WhatTheStackInitializer E at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:22) E at android.content.ContentProvider.attachInfo(ContentProvider.java:2388) E at android.content.ContentProvider.attachInfo(ContentProvider.java:2358) E at android.app.ActivityThread.installProvider(ActivityThread.java:7130) E ... 10 more E Caused by: java.lang.ClassNotFoundException: com.haroldadmin.whatthestack.WhatTheStackInitializer E at java.lang.Class.classForName(Native Method) E at java.lang.Class.forName(Class.java:454) E at java.lang.Class.forName(Class.java:379) E at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:18) E ... 13 more E Caused by: java.lang.ClassNotFoundException: com.haroldadmin.whatthestack.WhatTheStackInitializer E ... 17 more ```
haroldadmin commented 4 years ago

Thanks for the contribution.

I was wondering, are you using WTS in release builds? If not, are you using R8 code minification in debug builds?

Either way, the consumer proguard rules should help. I'm slightly concerned that people might think its okay to keep WhatTheStack in release builds due the presence of proguard rules.

msfjarvis commented 4 years ago

Thanks for the contribution.

I was wondering, are you using WTS in release builds? If not, are you using R8 code minification in debug builds?

Either way, the consumer proguard rules should help. I'm slightly concerned that people might think its okay to keep WhatTheStack in release builds due the presence of proguard rules.

I deploy release binaries for QA testing where I keep LeakCanary and WTS enabled to allow for the final product to be tested while still retaining the ability to report bugs. If you want to discourage release usage you can probably go with how LeakCanary does it by requiring to override a Boolean resource or throwing an exception at init. Not sure if that's something androidx.startup would allow but it's a good approach IMO.