Files
flipper/desktop/plugins/public/leak_canary/docs/setup.mdx
Flipper Bot 714ee44929 Flipper Release: v0.157.0
Summary: Releasing version 0.157.0

Reviewed By: passy

Differential Revision: D38382530

fbshipit-source-id: 687ff275c280587d4d40c9c2d8622a1d0ba1adaa
2022-08-03 05:02:01 -07:00

46 lines
1.4 KiB
Plaintext

import useBaseUrl from '@docusaurus/useBaseUrl';
import Link from '@docusaurus/Link';
To setup the <Link to={useBaseUrl("/docs/features/plugins/leak-canary")}>Leak Canary plugin</Link>, take the following steps:
1. Ensure that you have an explicit dependency in your application's `build.gradle` including the plugin dependency, such as is shown in the following snippet:
```groovy
dependencies {
debugImplementation 'com.facebook.flipper:flipper-leakcanary2-plugin:0.157.0'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'
}
```
2. Update your the `onCreate` method in you `Application` to add the LeakCanary2 plugin to Flipper and the Flipper listener to LeakCanary:
```kt
import com.facebook.flipper.plugins.leakcanary2.FlipperLeakListener
import com.facebook.flipper.plugins.leakcanary2.LeakCanary2FlipperPlugin
...
override fun onCreate() {
super.onCreate()
/*
set the flipper listener in leak canary config
*/
LeakCanary.config = LeakCanary.config.copy(
onHeapAnalyzedListener = FlipperLeakListener()
)
SoLoader.init(this, false)
if (BuildConfig.DEBUG && FlipperUtils.shouldEnableFlipper(this)) {
val client = AndroidFlipperClient.getInstance(this)
/*
add leak canary plugin to flipper
*/
client.addPlugin(LeakCanary2FlipperPlugin())
client.start()
}
}
```