Summary: **Currently, the Leak Canary plugins is broken, see this screenshot (unable to expand):** <img width="1359" alt="Screen Shot 2022-01-29 at 2 06 33 PM" src="https://user-images.githubusercontent.com/745166/151679662-9d8e8eb6-c19c-4008-9821-1c2c1af92351.png"> **This fix repairs and improves the UI:** <img width="1350" alt="Screen Shot 2022-01-29 at 2 06 03 PM" src="https://user-images.githubusercontent.com/745166/151679677-7965604c-dd04-4ee5-bc8e-d53a82da1bd7.png"> ## Changelog - Fixes UI to enable showing leak trace - Upgrades LackCanary dependency from 2.6 to 2.8.1 - Makes Kotlin and LC `compileOnly` dependencies in order to prevent conflict for the users - Updates documentation Pull Request resolved: https://github.com/facebook/flipper/pull/3367 Test Plan: See demo at https://github.com/hbmartin/leakcanary/tree/flipper-demo/leakcanary-android-sample **Static Docs Preview: flipper** |[Full Site](https://our.intern.facebook.com/intern/staticdocs/eph/D33915179/V3/flipper/)| |**Modified Pages**| Reviewed By: passy Differential Revision: D33915179 Pulled By: cekkaewnumchai fbshipit-source-id: 9698dba23ab475c8cd84e4c222dfc41712b05a1e
43 lines
1.1 KiB
Plaintext
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.132.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!
|