Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

When I run my Android App I get the following error:

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.<init>(Inflater.java:82)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.android.okio.GzipSource.<init>(GzipSource.java:57)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.android.okhttp.internal.http.HttpEngine.initContentStream(HttpEngine.java:490)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:680)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:388)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:332)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:500)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.google.android.gms.http.GoogleHttpClient.a(SourceFile:806)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.google.android.gms.http.GoogleHttpClient.b(SourceFile:770)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.google.android.gms.http.GoogleHttpClient.execute(SourceFile:673)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.google.android.gms.http.GoogleHttpClient.execute(SourceFile:664)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.google.android.gms.playlog.uploader.b.a(SourceFile:332)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.google.android.gms.playlog.uploader.b.a(SourceFile:227)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.google.android.gms.playlog.uploader.b.a(SourceFile:199)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.google.android.gms.playlog.uploader.UploaderService.a(SourceFile:39)
10-12 16:46:44.719 2710-2719/? E/StrictMode:     at com.google.android.gms.gcm.af.run(SourceFile:130)

What does this error mean and how can I resolve it?

like image 564
stephan1002 Avatar asked Oct 12 '15 16:10

stephan1002


1 Answers

Could you share your code? Did you use the emulator to run your app or a phisical device?

Because there may be many reasons:

  1. You have opened something but never close them. Closable has a close() method which you must call to manually release the opened resources associated with the component when you no longer need it (for example in a finally block).

  2. Also, that error message shows up when there is a problem in AndroidManifest.xml. For example when the <activity> tag accidentally went out of <application>

  3. Emulators have StrictMode on by default, on real devices it can be turned on in code via:

Code:

StrictMode.setVmPolicy (new StrictMode.VmPolicy.Builder().detectAll().penaltyLog()
                                          .penaltyDeath().build());
like image 191
eldivino87 Avatar answered Oct 27 '22 00:10

eldivino87