Add Leakcanary to the project (#655)

This commit is contained in:
Saurav Tiwary 2018-03-23 22:04:56 +05:30 committed by Rashiq
parent c7abb86eae
commit ebac71aeed
2 changed files with 18 additions and 0 deletions

View File

@ -116,6 +116,11 @@ dependencies {
// Mockito
testImplementation "org.mockito:mockito-core:2.7.22"
androidTestImplementation "org.mockito:mockito-android:2.7.22"
// Leak canary
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
}
// Set custom app import directory

View File

@ -21,6 +21,8 @@ import android.content.Context;
import android.support.multidex.MultiDexApplication;
import android.support.v7.app.AppCompatDelegate;
import com.squareup.leakcanary.LeakCanary;
import org.kiwix.kiwixmobile.di.components.ApplicationComponent;
import org.kiwix.kiwixmobile.di.components.DaggerApplicationComponent;
import org.kiwix.kiwixmobile.di.modules.ApplicationModule;
@ -39,6 +41,17 @@ public class KiwixApplication extends MultiDexApplication {
return application;
}
@Override
public void onCreate() {
super.onCreate();
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);
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);