W/System: A resource failed to call release

后端 未结 3 4203
甜味超标
甜味超标 2020-12-11 03:00

As the title says. When using the console of AndroidStudio on my app it shows:

W/System: A resource failed to call release.

Sometimes it is said multiple ti

3条回答
  •  一个人的身影
    2020-12-11 03:16

    The answer from @guest works, but you can achieve the exact same thing without resorting to reflection using Strict Mode. Specifically, something like:

    StrictMode.setVmPolicy(new VmPolicy.Builder()
                     .detectLeakedClosableObjects()
                     .penaltyLog()
                     .build());
    

    In general, strict mode can do much more for you though (see link above to doc), and all you need to do for a default setup is:

    StrictMode.enableDefaults();  # <-- This includes warning on leaked closeables
    

提交回复
热议问题