Weird FileNotFoundException exception from Android app in the wild

后端 未结 2 552
无人及你
无人及你 2021-01-18 07:25

I\'m working on an Android app which is now in production, and am occasionally seeing exceptions (reported via airbrake) with stuff like this:

[1.0.4] java.l         


        
相关标签:
2条回答
  • 2021-01-18 07:45

    I never did track down the exact cause of this problem, but based on my experience developing the app in question I believe it was caused by hitting the memory limit for the activity. After your activity runs out of memory, it seems that all sorts of strange errors can happen, including stuff like this.

    When I made other improvements to the app's memory management (particularly by using SoftReference with Bitmaps), these type of exceptions starting appearing less frequently.

    0 讨论(0)
  • 2021-01-18 07:53

    I guess, this devices are running Android 1.5

    From the Docs on "Providing the Best Device Compatibility with Resources":

    Providing default resources is important not only because your application might run on a configuration you had not anticipated, but also because new versions of Android sometimes add configuration qualifiers that older versions do not support. If you use a new resource qualifier, but maintain code compatibility with older versions of Android, then when an older version of Android runs your application, it will crash if you do not provide default resources, because it cannot use the resources named with the new qualifier. For example, if your minSdkVersion is set to 4, and you qualify all of your drawable resources using night mode (night or notnight, which were added in API Level 8), then an API level 4 device cannot access your drawable resources and will crash. In this case, you probably want notnight to be your default resources, so you should exclude that qualifier so your drawable resources are in either drawable/ or drawable-night/.

    Since you are using the -hdpi-qualifier, this might be the problem because those where introduced in Android 1.6 (API-Level 4) and are therefore not available under Android 1.5

    See this topic: Drawable-hdpi, Drawable-mdpi, Drawable-ldpi Android

    So, providing some fallback-drawbale resources in the res/drawable-folder might solve your issue.


    There seams to be a Bug based on my original idea which is described here: NotFoundException and FileNotFoundException when running app on Android 1.5

    It seams that the error is thrown for the next resource. So be sure to provide fallback's for every drawable in the res/drawable-folder.

    This addresses Android 1.5, I'm not sure if this is still a problem in Android 2.3, but it seams that different manufactures handle those things different.

    0 讨论(0)
提交回复
热议问题