From b03050783aa5f956fb922129db85b451c52bde3d Mon Sep 17 00:00:00 2001 From: Fernando Cejas Date: Sat, 30 Jan 2016 15:54:30 +0100 Subject: [PATCH] Add Leak canary to the project. --- buildsystem/dependencies.gradle | 6 ++++++ presentation/build.gradle | 3 +++ .../sample/presentation/AndroidApplication.java | 10 +++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/buildsystem/dependencies.gradle b/buildsystem/dependencies.gradle index 7ce4470..aedb3ab 100644 --- a/buildsystem/dependencies.gradle +++ b/buildsystem/dependencies.gradle @@ -31,6 +31,8 @@ ext { espressoVersion = '2.0' testingSupportLibVersion = '0.1' + //Development + leakCanaryVersion = '1.3.1' presentationDependencies = [ daggerCompiler: "com.google.dagger:dagger-compiler:${daggerVersion}", @@ -79,4 +81,8 @@ ext { mockito: "org.mockito:mockito-core:${mockitoVersion}", robolectric: "org.robolectric:robolectric:${robolectricVersion}", ] + + developmentDependencies = [ + leakCanary: "com.squareup.leakcanary:leakcanary-android:${leakCanaryVersion}", + ] } diff --git a/presentation/build.gradle b/presentation/build.gradle index 5c256f4..7c2c351 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -61,6 +61,7 @@ android { dependencies { def presentationDependencies = rootProject.ext.presentationDependencies def presentationTestDependencies = rootProject.ext.presentationTestDependencies + def developmentDependencies = rootProject.ext.developmentDependencies compile project(':domain') compile project(':data') @@ -78,4 +79,6 @@ dependencies { androidTestCompile presentationTestDependencies.dexmakerMockito androidTestCompile presentationTestDependencies.espresso androidTestCompile presentationTestDependencies.testingSupportLib + + debugCompile developmentDependencies.leakCanary } diff --git a/presentation/src/main/java/com/fernandocejas/android10/sample/presentation/AndroidApplication.java b/presentation/src/main/java/com/fernandocejas/android10/sample/presentation/AndroidApplication.java index d8cdb4e..006bb11 100644 --- a/presentation/src/main/java/com/fernandocejas/android10/sample/presentation/AndroidApplication.java +++ b/presentation/src/main/java/com/fernandocejas/android10/sample/presentation/AndroidApplication.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -19,6 +19,7 @@ import android.app.Application; import com.fernandocejas.android10.sample.presentation.internal.di.components.ApplicationComponent; import com.fernandocejas.android10.sample.presentation.internal.di.components.DaggerApplicationComponent; import com.fernandocejas.android10.sample.presentation.internal.di.modules.ApplicationModule; +import com.squareup.leakcanary.LeakCanary; /** * Android Main Application @@ -30,6 +31,7 @@ public class AndroidApplication extends Application { @Override public void onCreate() { super.onCreate(); this.initializeInjector(); + this.initializeLeakDetection(); } private void initializeInjector() { @@ -41,4 +43,10 @@ public class AndroidApplication extends Application { public ApplicationComponent getApplicationComponent() { return this.applicationComponent; } + + private void initializeLeakDetection() { + if (BuildConfig.DEBUG) { + LeakCanary.install(this); + } + } }