Add Leak canary to the project.

This commit is contained in:
Fernando Cejas
2016-01-30 15:54:30 +01:00
parent 12d03b1416
commit b03050783a
3 changed files with 18 additions and 1 deletions

View File

@@ -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}",
]
}

View File

@@ -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
}

View File

@@ -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);
}
}
}