StrictMode policy violation: android.os.strictmode.LeakedClosableViolation in my app?
Asked Answered
I

0

30

New to Android development and trying out StrictMode on my app for the first time. I noticed the following and would like to know if this is a problem in my app or a library—it’s not readily clear to me.

Thank you!

D/StrictMode: StrictMode policy violation: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. Callsite: readFromParcel
    at android.os.StrictMode$AndroidCloseGuardReporter.report(StrictMode.java:1929)
    at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:305)
    at android.view.SurfaceControl.finalize(SurfaceControl.java:1104)
    at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:291)
    at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:278)
    at java.lang.Daemons$Daemon.run(Daemons.java:139)
    at java.lang.Thread.run(Thread.java:923)
Idomeneus answered 25/11, 2020 at 19:21 Comment(8)
Have you resolved this? I've run into the same problem (devices with API 30 seem to be affected the most)Boyfriend
@AlexShevchyshen Not yet. For right now I’ve only tried StrictMode on the latest API and have not done all the other APIs my app supports.Idomeneus
I found this issue, looks like only API30 devices are affected, probably something has to do with the layout inspector issuetracker.google.com/issues/167533582Boyfriend
@AlexShevchyshen Nice sleuthing. Although, Google says this is fixed in AS 4.2 Canary 12, but that doesn’t appear to be the case.Idomeneus
yeah, but the comment right above mine on issue tracker says that it is not actually fixed in canary 12 (I cannot confirm because I'm either using stable or Beta build)Boyfriend
it's may be from any inspector (database or layout) , but when I disconnect the device from android studio it works fineVile
I'm seeing this on an API 31 device. There is no "attached stack trace" so it's hard to know where to look.Sufficient
Any news? My app also uses API 30 and keeps printing "A resource failed to call close" (and/or with "release"). This happens randomly, either just before or just after onCreateView is called. It also started happening later randomly once I added code to download files from a server with HttpURLConnection, InputStream and FileOutputStream (yes, I'm closing all of them). My StrictMode log looks exactly like yours, sometimes it also says "Callsite: close". Were/are you possibly using an AsyncTask? I'm only using that, no threads or anything else and never call Thread.start myself.Gader

© 2022 - 2024 — McMap. All rights reserved.