We see an stream of the following crashes, all on Android 4.3 Samsung Galaxy s3
java.util.concurrent.TimeoutException: android.content.res.AssetManager$AssetInputStream.finalize() timed out after 10 seconds
at android.content.res.AssetManager$AssetInputStream.close(AssetManager.java:559)
at android.content.res.AssetManager$AssetInputStream.finalize(AssetManager.java:592)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:187)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:170)
at java.lang.Thread.run(Thread.java:841)
Help anyone?
Whenever you do read/write operation using StreamReader/StreamWriter classes, please make sure you are calling ioStream.close()
inside first try{}
block. Something like this:
AssetManager AssetManager = mContext.getAssets();
try {
InputStream is = AssetManager.open("sample.json");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
} catch (Exception ex) {
ex.printStackTrace();
}
Even If you have another try{}
block under catch/finally {}
block still it will throw above exception.
instead you can assign ioStream = null
in catch/finally {}
block.
catch (Exception ex) {
// If ioStream object is outside the try block
ioStream = null;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With