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

Add ProGuard rules to keep WhatTheStackInitializer #7

Merged
merged 1 commit into from Jun 27, 2020
Merged

Add ProGuard rules to keep WhatTheStackInitializer #7

merged 1 commit into from Jun 27, 2020

Conversation

msfjarvis
Copy link
Contributor

@msfjarvis msfjarvis commented Jun 25, 2020

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

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
@haroldadmin
Copy link
Owner

haroldadmin commented Jun 25, 2020

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
Copy link
Contributor Author

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.

@haroldadmin haroldadmin merged commit fd2cfa9 into haroldadmin:master Jun 27, 2020
@msfjarvis msfjarvis deleted the proguard branch June 27, 2020 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants