From fba4adf0f1bb51600883ada0e0fbc76ad448a3af Mon Sep 17 00:00:00 2001 From: mhutti1 Date: Sun, 1 Apr 2018 20:19:28 +0100 Subject: [PATCH] Add leak canary stub as a dependency for all builds by default --- app/build.gradle | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 037420595..c69365fed 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -120,9 +120,19 @@ dependencies { androidTestImplementation "org.mockito:mockito-android:2.7.22" // Leak canary - debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4' - releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4' - testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4' + implementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4' + // Only enable leak canary in debug builds + configurations.all { config -> + if (config.name.contains('debug') || config.name.contains("Debug")) { + config.resolutionStrategy.eachDependency { details -> + if (details.requested.group == 'com.squareup.leakcanary' && + details.requested.name == 'leakcanary-android-no-op') { + details.useTarget(group: details.requested.group, name: 'leakcanary-android', + version: details.requested.version) + } + } + } + } } // Set custom app import directory