无法使用 LeakCanary,因为 org.junit.Test 类依赖关系在外部库中



我正在尝试使用LeakCanary来查找Android应用程序中的内存泄漏。我使用的是安卓工作室。

当我开始调试我的应用程序时;LeakCanary当前已禁用:在类路径中找到测试类org.unit.test"消息

"org.junit.test";班级来自外部图书馆。

如何强制启用LeakCanary?

LeakCanary通过检测org.junit.Test在类路径中,在测试中自动禁用自己。不幸的是,有些应用程序在其应用程序调试类路径中提供Junit(例如,当使用OkHttpMockWebServer时(。您可以自定义用于检测测试的类:

<resources>
<string name="leak_canary_test_class_name">assertk.Assert</string>
</resources>

需要更新文档(此处跟踪:https://github.com/square/leakcanary/issues/1968)

有时检查模块build.gradle文件并找到"实现";而不是";testImplementation";或";androidTestImplementation";测试依赖关系。它可能会导致此问题。

最新更新