-
Notifications
You must be signed in to change notification settings - Fork 4k
Crash in non-debuggable builds #1806
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
Conversation
leakcanary-object-watcher-android/src/main/java/leakcanary/AppWatcher.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some feedback, but other than that I like the general direction!
What do I run to check this crashes as expected? Also, probably need to update the XML in the sample app?
leakcanary-object-watcher-android/src/main/java/leakcanary/AppWatcher.kt
Outdated
Show resolved
Hide resolved
|
||
if (application.resources.getBoolean(R.bool.leak_canary_allow_in_non_debuggable_build)) { | ||
// AppWatcher is disabled by default for non-debuggable builds, but we have a developer opt-in. | ||
AppWatcher.config = AppWatcher.config.copy(enabled = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's interesting! Hadn't thought of this, makes sense to reenable.
leakcanary-android-core/src/main/java/leakcanary/internal/InternalLeakCanary.kt
Outdated
Show resolved
Hide resolved
leakcanary-android-core/src/main/java/leakcanary/internal/InternalLeakCanary.kt
Outdated
Show resolved
Hide resolved
If you're sure you want to include LeakCanary in a non-debuggable build, you can disable this | ||
check by overriding the bool/leak_canary_allow_in_non_debuggable_build resource and setting | ||
the value to 'true'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to add a corresponding section in the Code recipes and have the error message point to that page with an anchor to a detailed description with xml snippet to copy&paste. Source code of those docs is located in /leakcanary/docs/recipes.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A link for just the last part on how to disable the runtime check? Or replace the whole message with a link?
PR updated.
The easiest way is manual testing. Setting up a release build of the sample app was painful. Adding
I added a code recipe with an XML snippet you can use to override the check during a manual test. I wouldn't modify the sample app in the repository because you don't want to encourage people to actually use this override. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Added couple comments related to wording.
Updated with suggested wording changes. |
@@ -105,6 +105,18 @@ In your leak reporting code: | |||
val retainedInstanceCount = AppWatcher.objectWatcher.retainedObjectCount | |||
``` | |||
|
|||
## LeakCanary in release builds | |||
|
|||
We **do not recommend** including LeakCanary in your production build. To avoid accidentally including the `com.squareup.leakcanary:leakcanary-android` dependency in a release build, LeakCanary crashes during initialization if the APK is not debuggable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this says both "production" and "release". We should ideally pick one, as changing vocabulary can be confusing. Probably release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!! I'll merge and follow up with the wording nit. |
Crash in release builds (really, any APK without
android:debuggable="true"
). Can be overridden by setting@bool/leak_canary_allow_in_non_debuggable_build
totrue
.Fixes #1804