Gradle 设置
debugCompile
'com.squareup.leakcanary:leakcanary-android:1.5.1'
releaseCompile
'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
testCompile
'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'@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; }
enabledStrictMode(); LeakCanary.
install(
this);}
private static void enabledStrictMode() { StrictMode.
setThreadPolicy(
new StrictMode.ThreadPolicy.Builder()
// .detectAll()
// .penaltyLog()
// .penaltyDeath()
// .build());}