Summary: Missing instructions to add RecordLeakService in manifest, missing this will crash the app. Pull Request resolved: https://github.com/facebook/flipper/pull/360 Differential Revision: D13817454 Pulled By: passy fbshipit-source-id: 5466ba1117510ffe0b2033b6b0913125fda08983
1.6 KiB
id, title
| id | title |
|---|---|
| leak-canary-plugin | LeakCanary |
The LeakCanary plugin provides developers with Flipper support for LeakCanary, an open source memory leak detection library.
Setup
Note: this plugin is only available for Android.
Ensure that you already have an explicit dependency in your application's
build.gradle, e.g.
dependencies {
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.1'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.1'
}
Android
First, add the plugin to your Flipper client instance:
import com.facebook.flipper.plugins.leakcanary.LeakCanaryFlipperPlugin;
client.addPlugin(new LeakCanaryFlipperPlugin());
Next, build a custom RefWatcher using RecordLeakService: (see LeakCanary docs for more information on RefWatcher)
import com.facebook.flipper.plugins.leakcanary.RecordLeakService;
RefWatcher refWatcher = LeakCanary.refWatcher(this)
.listenerServiceClass(RecordLeakService.class);
.buildAndInstall();
Then, add the RecordLeakService in your debug variant AndroidManifest.xml.
<service android:name="com.facebook.flipper.plugins.leakcanary.RecordLeakService" />
Usage
Leaks detected by LeakCanary will appear automatically in Flipper. Each leak will display a hierarchy of objects, beginning from the garbage collector root and ending at the leaked class. Selecting any object in this list will display contents of the object's various fields.