Skip to content

Crash in non-debuggable builds - #1806

Merged
pyricau merged 1 commit into
square:masterfrom
cketti:crash_in_release_build
May 1, 2020
Merged

Crash in non-debuggable builds#1806
pyricau merged 1 commit into
square:masterfrom
cketti:crash_in_release_build

Conversation

@cketti

@cketti cketti commented Apr 25, 2020

Copy link
Copy Markdown
Contributor

Crash in release builds (really, any APK without android:debuggable="true"). Can be overridden by setting @bool/leak_canary_allow_in_non_debuggable_build to true.

Fixes #1804

@CLAassistant

CLAassistant commented Apr 25, 2020

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread leakcanary-object-watcher-android/src/main/java/leakcanary/AppWatcher.kt Outdated

@pyricau pyricau left a comment

Copy link
Copy Markdown
Member

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?

Comment thread leakcanary-object-watcher-android/src/main/java/leakcanary/AppWatcher.kt Outdated

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)

Copy link
Copy Markdown
Member

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.

Comment thread leakcanary-android-core/src/main/java/leakcanary/internal/InternalLeakCanary.kt Outdated
Comment thread leakcanary-android-core/src/main/java/leakcanary/internal/InternalLeakCanary.kt Outdated
Comment on lines +164 to +166
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'.

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor Author

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?

@cketti

cketti commented Apr 28, 2020

Copy link
Copy Markdown
Contributor Author

PR updated.

What do I run to check this crashes as expected?

The easiest way is manual testing. Setting up a release build of the sample app was painful. Adding debuggable false to the debug buildTypes config of the sample app also does the trick and is less hassle.

Also, probably need to update the XML in the sample app?

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.

@Armaxis Armaxis left a comment

Copy link
Copy Markdown
Member

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.

Comment thread docs/recipes.md Outdated
Comment thread docs/recipes.md Outdated
@cketti

cketti commented Apr 29, 2020

Copy link
Copy Markdown
Contributor Author

Updated with suggested wording changes.

Comment thread docs/recipes.md

## 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.

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welp, I wanted to make a PR but I pushed to master instead. Oh well.

28d5378

🤫 don't tell anyone

@pyricau

pyricau commented May 1, 2020

Copy link
Copy Markdown
Member

Thanks!! I'll merge and follow up with the wording nit.

@pyricau
pyricau merged commit 40ece74 into square:master May 1, 2020
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.

LeakCanary should crash in release builds

4 participants