Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find symbol class AndroidExcludedRefs, DisplayLeakService,

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?

like image 317
Sebastian Engel Avatar asked Oct 31 '22 18:10

Sebastian Engel


1 Answers

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.

like image 109
Sebastian Engel Avatar answered Nov 13 '22 01:11

Sebastian Engel