我当前的android应用程序定期报告此logcat消息
W/System: A resource failed to call close.
在寻找如何确定根本原因后,我尝试了以下方法,但都没有奏效。。。
StrictMode.setVmPolicy(
VmPolicy.Builder()
.detectLeakedClosableObjects()
.penaltyDeath()
.build()
)
这个
StrictMode.setVmPolicy(
VmPolicy.Builder()
.detectAll()
.penaltyDeath()
.build()
)
和
try {
Class.forName("dalvik.system.CloseGuard")
.getMethod("setEnabled", Boolean::class.javaPrimitiveType)
.invoke(null, true)
} catch (e: ReflectiveOperationException) {
throw java.lang.RuntimeException(e)
}
我的应用程序针对这些版本的android
compileSdkVersion 32
buildToolsVersion "32.0.0"
defaultConfig {
applicationId "com.my.app"
minSdkVersion 26
targetSdkVersion 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
我哪里错了?
如何发现哪个资源没有调用close?