Files
flipper/desktop/plugins/public/leak_canary/docs/setup.mdx
Flipper Bot 4b07c0f9d9 Flipper Release: v0.145.0
Summary: Releasing version 0.145.0

Reviewed By: cekkaewnumchai

Differential Revision: D36168545

fbshipit-source-id: 4cb68eb9c8c80a0018c2a617ce0704fd18ff0b47
2022-05-06 05:14:39 -07:00

43 lines
1.1 KiB
Plaintext

Ensure that you already have an explicit dependency in your application's
`build.gradle` including the plugin dependency, e.g.
```groovy
dependencies {
debugImplementation 'com.facebook.flipper:flipper-leakcanary2-plugin:0.145.0'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'
}
```
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()
}
}
```
That's it!