A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks

后端 未结 6 1787
心在旅途
心在旅途 2020-11-29 11:18

i am getting this message in logcat A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource l

6条回答
  •  萌比男神i
    2020-11-29 11:43

    if you see something like:

    10-12 16:46:44.719 2710-2719/? E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
    10-12 16:46:44.719 2710-2719/? E/StrictMode: java.lang.Throwable: Explicit termination method 'end' not called
    10-12 16:46:44.719 2710-2719/? E/StrictMode:     at dalvik.system.CloseGuard.open(CloseGuard.java:184)
    10-12 16:46:44.719 2710-2719/? E/StrictMode:     at java.util.zip.Inflater.(Inflater.java:82)
    10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.android.okio.GzipSource.(GzipSource.java:57)
    10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.android.okhttp.internal.http.HttpEngine.initContentStream(HttpEngine.java:490)
    

    in your stacktrace, there is a known bug in older versions of okhttp that you can avoid by forcing the use of a newer version in your gradle file.

    compile 'com.squareup.okhttp3:okhttp:3.2.0'

    that solved a very similar problem for me at least.

提交回复
热议问题