Files
flipper/docs/setup/leak-canary-plugin.md
Pascal Hartig 3d31906b95 Flipper Release: v0.27.0
Summary:
**Highlights**

- Sample Android APK now available as download on this very release page.
- Memory usage viewer available for KaiOS devices.

Full changelog: https://github.com/facebook/flipper/compare/v0.26.0...master

Reviewed By: jknoxville

Differential Revision: D18245037

fbshipit-source-id: 0d49012c1ebd11b406a2bf81e5b41e823ced0c05
2019-10-31 08:43:32 -07:00

1.2 KiB

id, title, sidebar_label
id title sidebar_label
leak-canary-plugin LeakCanary Setup LeakCanary

Ensure that you already have an explicit dependency in your application's build.gradle including the plugin dependency, e.g.

dependencies {
  debugImplementation 'com.facebook.flipper:flipper-leakcanary-plugin:0.27.0'
  debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.1'
  releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.1'
}

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" />