我正在尝试使用 LeakCanary 来查找我的 Android 应用程序中的内存泄漏。我正在使用安卓工作室。
当我开始调试我的应用程序时,我看到“LeakCanary 当前已禁用:在类路径中找到测试类 org.junit.Test。”信息。
“org.junit.test”类来自外部库。
如何强制启用 LeakCanary?
最佳答案
LeakCanary 在测试中通过检测到 org.junit.Test
自动禁用自身。在类路径中。不幸的是,一些应用程序在他们的应用程序调试类路径中提供了 Junit(例如,当使用 OkHttp MockWebServer 时)。您可以自定义用于检测测试的类:
<resources>
<string name="leak_canary_test_class_name">assertk.Assert</string>
</resources>
该文档需要更新(在此处跟踪:https://github.com/square/leakcanary/issues/1968)
关于java - 由于外部库中的 org.junit.Test 类依赖关系,无法使用 LeakCanary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65117473/