Summary:
BUG:
{F157319747}
Reviewed By: passy
Differential Revision: D15181532
fbshipit-source-id: cb0f91e7b90b479200cb57c496ae34c87ad35001
39 lines
1.1 KiB
Markdown
39 lines
1.1 KiB
Markdown
---
|
|
id: leak-canary-plugin
|
|
title: LeakCanary Setup
|
|
sidebar_label: LeakCanary
|
|
---
|
|
|
|
Ensure that you already have an explicit dependency in your application's
|
|
`build.gradle`, e.g.
|
|
|
|
```groovy
|
|
dependencies {
|
|
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:
|
|
```java
|
|
import com.facebook.flipper.plugins.leakcanary.LeakCanaryFlipperPlugin;
|
|
|
|
client.addPlugin(new LeakCanaryFlipperPlugin());
|
|
```
|
|
|
|
Next, build a custom RefWatcher using RecordLeakService: (see [LeakCanary docs](https://github.com/square/leakcanary/wiki/Customizing-LeakCanary#uploading-to-a-server) for more information on RefWatcher)
|
|
```java
|
|
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.
|
|
|
|
```xml
|
|
<service android:name="com.facebook.flipper.plugins.leakcanary.RecordLeakService" />
|
|
```
|