Skip to content

Commit

Permalink
Add Leak canary to the project.
Browse files Browse the repository at this point in the history
  • Loading branch information
android10 committed Jan 30, 2016
1 parent 12d03b1 commit b030507
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions buildsystem/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ ext {
espressoVersion = '2.0'
testingSupportLibVersion = '0.1'

//Development
leakCanaryVersion = '1.3.1'

presentationDependencies = [
daggerCompiler: "com.google.dagger:dagger-compiler:${daggerVersion}",
Expand Down Expand Up @@ -79,4 +81,8 @@ ext {
mockito: "org.mockito:mockito-core:${mockitoVersion}",
robolectric: "org.robolectric:robolectric:${robolectricVersion}",
]

developmentDependencies = [
leakCanary: "com.squareup.leakcanary:leakcanary-android:${leakCanaryVersion}",
]
}
3 changes: 3 additions & 0 deletions presentation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -78,4 +79,6 @@ dependencies {
androidTestCompile presentationTestDependencies.dexmakerMockito
androidTestCompile presentationTestDependencies.espresso
androidTestCompile presentationTestDependencies.testingSupportLib

debugCompile developmentDependencies.leakCanary
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -19,6 +19,7 @@
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
Expand All @@ -30,6 +31,7 @@ public class AndroidApplication extends Application {
@Override public void onCreate() {
super.onCreate();
this.initializeInjector();
this.initializeLeakDetection();
}

private void initializeInjector() {
Expand All @@ -41,4 +43,10 @@ private void initializeInjector() {
public ApplicationComponent getApplicationComponent() {
return this.applicationComponent;
}

private void initializeLeakDetection() {
if (BuildConfig.DEBUG) {
LeakCanary.install(this);
}
}
}

0 comments on commit b030507

Please sign in to comment.