Files
flipper/desktop/plugins/public/leak_canary/docs/setup.mdx
Flipper Bot 65111a7ecc Flipper Release: v0.128.4
Summary: Releasing version 0.128.4

Reviewed By: passy

Differential Revision: D33585348

fbshipit-source-id: 67a69573b1d4524abe1c643598e438133ee7c048
2022-01-14 09:49:48 -08:00

44 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.128.4'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6'
}
```
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()
setupFlipper()
/*
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!