Skip to content

Commit

Permalink
[ADDED] [#59] Leakcanary memory leak detection library from square.
Browse files Browse the repository at this point in the history
  • Loading branch information
hossain-khan committed Oct 13, 2016
1 parent 6e6ff20 commit 1e88aa8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ This is my personal project to experiment with following tools & technologies
* Database (local caching - Realm (maybe?))
* Scheduler - data syncing
* Google Play Alpha Beta release
* LeakCanary
* LeakCanary _(See [#60](https://github.com/amardeshbd/android-daily-headlines/pull/60))_

I'll try to update references for these items when I use in the app :sunglasses:
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@ ext {
jodaTimeVersion = '2.9.4'
glassfishJavaxAnnotationVersion = '10.0-b28'
timberLibraryVersion = '4.3.1'
leakcanaryLibraryVersion = '1.5'
}
7 changes: 7 additions & 0 deletions core-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ dependencies {
compile "com.squareup.picasso:picasso:$rootProject.picassoVersion"


// leakcanary - A memory leak detection library for Android and Java.
// https://github.com/square/leakcanary
debugCompile "com.squareup.leakcanary:leakcanary-android:$rootProject.leakcanaryLibraryVersion"
releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:$rootProject.leakcanaryLibraryVersion"


// ----------------------------------------------------------------
// Android Unit and Instrumentation test
// ----------------------------------------------------------------
Expand All @@ -82,4 +88,5 @@ dependencies {
})
compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
testCompile "junit:junit:$rootProject.junitVersion"
testCompile "com.squareup.leakcanary:leakcanary-android-no-op:$rootProject.leakcanaryLibraryVersion"
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import android.app.Application;
import android.content.Context;

import com.squareup.leakcanary.LeakCanary;

import info.hossainkhan.android.core.dagger.components.AppComponent;
import info.hossainkhan.android.core.dagger.components.DaggerAppComponent;
import info.hossainkhan.android.core.dagger.modules.InteractorsModule;
Expand All @@ -46,10 +48,20 @@ public class CoreApplication extends Application {
public void onCreate() {
super.onCreate();

initLeakCanary();
initAppComponent();
initLogger();
}

private void initLeakCanary() {
if (LeakCanary.isInAnalyzerProcess(this)) {
// This process is dedicated to LeakCanary for heap analysis.
// You should not init your app in this process.
return;
}
LeakCanary.install(this);
}

private void initLogger() {
if (ENABLE_LOGGING) {
android.util.Log.i(TAG, "Planting tree for timber logger.");
Expand Down

0 comments on commit 1e88aa8

Please sign in to comment.