title: how to identify root cause of W/System: A resource failed to call close. on Android
body: <p>my current android application regularly reports this logcat message</p>
  <pre><code>W/System: A resource failed to call close. 
  </code></pre>
  <p>having searched for how to identify the root cause i have tried the following approaches, none of which have worked...</p>
  <pre><code>StrictMode.setVmPolicy(
                  VmPolicy.Builder()
                      .detectLeakedClosableObjects()
                      .penaltyDeath()
                      .build()
              )
  </code></pre>
  <p>and this</p>
  <pre><code>StrictMode.setVmPolicy(
                  VmPolicy.Builder()
                      .detectAll()
                      .penaltyDeath()
                      .build()
              )
  </code></pre>
  <p>and</p>
  <pre><code>try {
              Class.forName(&quot;dalvik.system.CloseGuard&quot;)
                  .getMethod(&quot;setEnabled&quot;, Boolean::class.javaPrimitiveType)
                  .invoke(null, true)
          } catch (e: ReflectiveOperationException) {
              throw java.lang.RuntimeException(e)
          }
  </code></pre>
  <p>my application targets these versions of android</p>
  <pre><code> compileSdkVersion 32
      buildToolsVersion &quot;32.0.0&quot;
  
      defaultConfig {
          applicationId &quot;com.my.app&quot;
          minSdkVersion 26
          targetSdkVersion 32
          versionCode 1
          versionName &quot;1.0&quot;
  
          testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
      }
  </code></pre>
  <p>where am i going wrong?</p>
  <p>how can i discover which resource is not calling close?</p>