Files
flipper/desktop/plugins/public/leak_canary/docs/setup.mdx
Vova-SH a46b7c2e78 Fix example code on setup leakCanary plugin (#4566)
Summary:
Fix sample for install leak canary plugin

## Changelog

add brackets on sample code

Pull Request resolved: https://github.com/facebook/flipper/pull/4566

Test Plan: -

Reviewed By: antonk52

Differential Revision: D43766946

Pulled By: passy

fbshipit-source-id: 4bded0122330ab4186745a9f5b2dcbd511318ee3
2023-03-03 10:38:42 -08: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")}>LeakCanary 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.183.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.FlipperLeakEventListener
import com.facebook.flipper.plugins.leakcanary2.LeakCanary2FlipperPlugin
...
override fun onCreate() {
super.onCreate()
/*
set the flipper listener in leak canary config
*/
LeakCanary.config = LeakCanary.config.run {
copy(eventListeners = eventListeners + FlipperLeakEventListener())
}
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()
}
}
```