Summary: Update the LeakCanary 2 plugin version in LeakCanary 2 plugin doc While adding the version as in the doc, the import statements didn't work. Upon checking the maven repo, I found out that the latest version is `0.81.0`. Updating to the latest version helps ## Changelog Updated LeakCanary 2 plugin docs to include the latest plugin version Pull Request resolved: https://github.com/facebook/flipper/pull/2085 Test Plan: Not necessary Reviewed By: mweststrate Differential Revision: D27265598 Pulled By: passy fbshipit-source-id: 2f82689c1f075c2f9cff8bae2831c9780a3db697
50 lines
1.2 KiB
Plaintext
50 lines
1.2 KiB
Plaintext
---
|
|
id: leak-canary-2-plugin
|
|
title: LeakCanary 2 Setup
|
|
sidebar_label: LeakCanary 2
|
|
---
|
|
|
|
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.81.0'
|
|
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!
|