图解Android anr 异常 成因&&定位&&解决方法

针对Android Anr问题 画了一个思维导图,对其成因、如何定位、解决方式,及使用到的工具做了一个梳理。抛砖引玉,如有不当或不完善之处,请留言批评指教。谢谢!


图解Android anr 异常 成因&&定位&&解决方法_第1张图片
image.png

原图PDF文件下载

更多《图解系列文章》的素材包括思维导图源文件请到图解技术素材库 Github仓库下载

StrictMode 初始化代码
@Override
public void onCreate() {
    super.onCreate();
    // 分别为MainThread和VM设置Strict Mode 
    if (BuildConfig.DEBUG) {
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
            .detectDiskReads()
            .detectDiskWrites()
            .detectNetwork()
            .detectResourceMismatches()
            .detectCustomSlowCalls()
            .penaltyDeath()
            .build());

        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
            .detectLeakedSqlLiteObjects()
            .detectLeakedClosableObjects()
            .detectLeakedRegistrationObjects()
            .detectActivityLeaks()
            .penaltyDeath()
            .build());
    }
}

你可能感兴趣的:(图解Android anr 异常 成因&&定位&&解决方法)