1.在build.gradle中加入引用,不同的編譯使用不同的引用:
dependencies {
? ? ? ? ? ? debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
? ? ? ? ? ? releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
}
2.修改application類:?
3.檢測fragment
public abstract class BaseFragment extends Fragment{
? ? ?@Override
? ? ?public void onDestroy(){
? ? ? ? ? ? ? super.onDestroy();
? ? ? ? ? ? ? RefWatcherrefWatcher=ExampleApplication.getRefWatcher(getActivity());
? ? ? ? ? ? ? refWatcher.watch(this);
? ? ? }
}