美文网首页
Android内存检测工具LeakCanary的使用

Android内存检测工具LeakCanary的使用

作者: 小二小二小二 | 来源:发表于2021-02-03 10:15 被阅读0次

    1.build.gradle添加配置

    implementation 'com.squareup.leakcanary:leakcanary-android:1.6'

    2.Application添加代码

    public class LaunchApplication extends Application {
    @Override
    public void onCreate() {
    super.onCreate();
    if (LeakCanary.isInAnalyzerProcess(this)) {//1
    // This process is dedicated to LeakCanary for heap analysis.
    // You should not init your app in this process.
    return;
    }
    LeakCanary.install(this);
    }
    }

    3.AndroidManifest.xml配置Applicaton

    <application
    android:name=".LaunchApplication"
    ...
    </applicaiton>

    相关文章

      网友评论

          本文标题:Android内存检测工具LeakCanary的使用

          本文链接:https://www.haomeiwen.com/subject/hjsptltx.html