我使用Picasso,所以我尝试使用OkHTTP管理捕获,在设置strick模式后,我现在得到" 在附加的堆栈跟踪中获取资源但从未发布"错误。
这是“应用程序类”中的内容。
@Override
public void onCreate() {
boolean DEVELOPER_MODE = true;
if (DEVELOPER_MODE) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork()
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.penaltyLog()
.penaltyDeath()
.build());
}
super.onCreate();
MultiDex.install(this);
Picasso.Builder b = new Picasso.Builder(this);
OkHttpDownloader downloader = new OkHttpDownloader(this, Integer.MAX_VALUE);
b.downloader(downloader);
Picasso built = b.build();
built.setIndicatorsEnabled(true);
built.setLoggingEnabled(true);
Picasso.setSingletonInstance(built);
}
我似乎问题出在new OkHttpDownloader(this, Integer.MAX_VALUE);
我该如何结束?
以下是错误:
A resource was acquired at attached stack trace but never released.
See java.io.Closeable for information on avoiding resource leaks.
java.lang.Throwable: Explicit termination method 'end' not called
at dalvik.system.CloseGuard.open(CloseGuard.java:180)
at java.util.zip.Inflater.<init>(Inflater.java:82)
at com.android.okhttp.okio.GzipSource.<init>(GzipSource.java:62)
at com.android.okhttp.internal.http.HttpEngine.unzip(HttpEngine.java:645)
at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:827)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:439)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl