Skip to main content

LeakCanary 2 Setup

Ensure that you already have an explicit dependency in your application's build.gradle including the plugin dependency, e.g.

dependencies {
debugImplementation 'com.facebook.flipper:flipper-leakcanary2-plugin:0.84.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

import com.facebook.flipper.plugins.leakcanary2.FlipperLeakListener
import com.facebook.flipper.plugins.leakcanary2.LeakCanary2FlipperPlugin
override fun 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

That's it!