首页 > 解决方案 > Android Leak Canary 2 无法转储堆

问题描述

我正在尝试在我的项目中实现 LeakCanary2 以检测内存泄漏,但它不断失败。

2020-07-03 19:37:41.834 17761-17799/com.example.projects D/LeakCanary: WRITE_EXTERNAL_STORAGE permission not granted, ignoring
2020-07-03 19:37:47.912 17761-17799/com.example.projects D/LeakCanary: Dumped heap file is 0 byte length
2020-07-03 19:37:47.914 17761-17799/com.example.projects D/LeakCanary: Failed to dump heap, will retry in 5000 ms
2020-07-03 19:37:47.914 17761-17799/com.example.projects D/LeakCanary: Rescheduling check for retained objects in 5000ms because failed to dump heap
2020-07-03 19:37:53.206 17761-17799/com.example.projects D/LeakCanary: Check for retained objects found 6 objects, dumping the heap
2020-07-03 19:37:53.214 17761-17799/com.example.projects D/LeakCanary: Removing 1 heap dumps
2020-07-03 19:37:53.222 17761-17799/com.example.projects D/LeakCanary: WRITE_EXTERNAL_STORAGE permission not granted, ignoring

它永远在无限循环中进行。如果我手动授予写入外部存储权限,它仍然无法正常工作。

依赖

debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'

在 Moto G7 上进行测试。在模拟器上测试时,它按预期工作。

标签: androidleakcanary

解决方案


推荐阅读