Skip to content

Commit b030507

Browse files
committed
Add Leak canary to the project.
1 parent 12d03b1 commit b030507

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

buildsystem/dependencies.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ ext {
3131
espressoVersion = '2.0'
3232
testingSupportLibVersion = '0.1'
3333

34+
//Development
35+
leakCanaryVersion = '1.3.1'
3436

3537
presentationDependencies = [
3638
daggerCompiler: "com.google.dagger:dagger-compiler:${daggerVersion}",
@@ -79,4 +81,8 @@ ext {
7981
mockito: "org.mockito:mockito-core:${mockitoVersion}",
8082
robolectric: "org.robolectric:robolectric:${robolectricVersion}",
8183
]
84+
85+
developmentDependencies = [
86+
leakCanary: "com.squareup.leakcanary:leakcanary-android:${leakCanaryVersion}",
87+
]
8288
}

presentation/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ android {
6161
dependencies {
6262
def presentationDependencies = rootProject.ext.presentationDependencies
6363
def presentationTestDependencies = rootProject.ext.presentationTestDependencies
64+
def developmentDependencies = rootProject.ext.developmentDependencies
6465

6566
compile project(':domain')
6667
compile project(':data')
@@ -78,4 +79,6 @@ dependencies {
7879
androidTestCompile presentationTestDependencies.dexmakerMockito
7980
androidTestCompile presentationTestDependencies.espresso
8081
androidTestCompile presentationTestDependencies.testingSupportLib
82+
83+
debugCompile developmentDependencies.leakCanary
8184
}

presentation/src/main/java/com/fernandocejas/android10/sample/presentation/AndroidApplication.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -19,6 +19,7 @@
1919
import com.fernandocejas.android10.sample.presentation.internal.di.components.ApplicationComponent;
2020
import com.fernandocejas.android10.sample.presentation.internal.di.components.DaggerApplicationComponent;
2121
import com.fernandocejas.android10.sample.presentation.internal.di.modules.ApplicationModule;
22+
import com.squareup.leakcanary.LeakCanary;
2223

2324
/**
2425
* Android Main Application
@@ -30,6 +31,7 @@ public class AndroidApplication extends Application {
3031
@Override public void onCreate() {
3132
super.onCreate();
3233
this.initializeInjector();
34+
this.initializeLeakDetection();
3335
}
3436

3537
private void initializeInjector() {
@@ -41,4 +43,10 @@ private void initializeInjector() {
4143
public ApplicationComponent getApplicationComponent() {
4244
return this.applicationComponent;
4345
}
46+
47+
private void initializeLeakDetection() {
48+
if (BuildConfig.DEBUG) {
49+
LeakCanary.install(this);
50+
}
51+
}
4452
}

0 commit comments

Comments
 (0)