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);
}
}