16

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?

RajeshVijayakumar
  • 10,281
  • 11
  • 57
  • 84
Guy
  • 12,250
  • 6
  • 53
  • 70
  • 2
    Are you using Crashlytics by an chance? – plinehan Jan 26 '15 at 23:57
  • @plinehan i do. Is it connected? – Guy Jan 27 '15 at 05:23
  • That's my current theory. It started happening in our app around March of last year after a Crashlytics update, and some Twitter employees confirmed that they saw similar crashes and ended up reverting the Crashlytics version. I've updated to the latest version of Crashlytics and I'll see if it has any improvement on that crash, but it will be a few weeks before the release makes it out to the public. – plinehan Jan 28 '15 at 17:51
  • I had a crash like this, and realized after checking the phone type that it was a Blackberry, not a true Android phone. – Carl Anderson May 26 '15 at 21:05
  • Anyone find any resolution?i hv also found issue in SM-G900I,5.0 – Sameer Z. Jul 15 '15 at 07:28
  • We face similar problem since long. It might be linked to crashlytics. has anyone figured it out? – rishabhmhjn Jun 01 '16 at 02:04
  • @CarlAnderson BlackBerry company has Android smartphones. Example: http://www.gsmarena.com/blackberry_priv-7587.php – android developer Jun 18 '17 at 16:49
  • @rishabhmhjn I have this issue without having Crashlytics. I got it recently via the Play Store, as they catch all crashes using their new feature that was recently added ("Vitals"). It's very similar to Crashlytics, though. Could be because Google bought them. – android developer Jun 18 '17 at 16:51
  • @androiddeveloper they didn't in 2015 when this question came up. – Carl Anderson Jun 21 '17 at 20:42
  • @CarlAnderson Who are "they" and what they "didn't" ? – android developer Jun 21 '17 at 20:47
  • @androiddeveloper why this isn't clear? My comment, that I wrote in May 2015, was that I only encountered this crash type on a BlackBerry phone. At that time BB didn't actually manufacture official Android phones, instead they used (broken) emulation to run Android apps on the BB OS, so this sort of crash wasn't worth fixing. You commented (tagging me!) with a BB phone that wasn't released until November(!) of 2015 that finally ran Android natively, as some sort of counterpoint? And so I tried to explain that they (BlackBerry) didn't have phones running native Android at the time of my comment – Carl Anderson Jul 20 '17 at 20:32
  • @CarlAnderson Oh ok. – android developer Jul 21 '17 at 19:37

1 Answers1

3

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;
}
RajeshVijayakumar
  • 10,281
  • 11
  • 57
  • 84