We are declaring our leak-canary dependencies as stated on the project's Github page.
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
So far, things are working fine. Now we started to exclude a known leak like that:
ExcludedRefs.Builder excludedRefsBuilder = AndroidExcludedRefs.createAppDefaults();
excludedRefsBuilder.staticField("com.google.android.chimera.container.a", "a");
refWatcher = LeakCanary.install(app, DisplayLeakService.class, excludedRefsBuilder.build());
Now when we switch to the release build type, classes like AndroidExcludedRefs, DisplayLeakService and ExcludedRefs are not found anymore, as the "no-op" dependency doesn't include them.
What's the best way to handle this?
Our LeakCanary setup is implemented in our class called DevToolsController. To solve the problem we put the default implementation into the "debug" source folder and a "no-op" implementation into the "release" source folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With