FileNotFoundException exception exception from Android application in the wild

I am working on an Android application that is currently in production, and sometimes I see exceptions (reported via airbrake) with such things:

[1.0.4] java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mycompany.android/com.mycompany.android.activities.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class <unknown> ... cut lots of stuff ... ### CAUSED BY ###: java.io.FileNotFoundException: res/drawable-hdpi/tab_active.9.png: AssetManager.java:-2:in `android.content.res.AssetManager.openNonAssetNative' AssetManager.java:406:in `android.content.res.AssetManager.openNonAsset' Resources.java:1706:in `android.content.res.Resources.loadDrawable' ... cut lots more stuff ... 

In testing, this view definitely worked on several HDPI devices, so the resource was fine. Before creating the final APK, I completely cleaned / rebuilt and, of course, sent the APK for internal testing. The fact that I get 1-2 exceptions, for example, for each version instead of 10,000, indicates that this resource is definitely properly packaged for most users.

I am completely at a dead end and unsure why it does not load on some phones. Has anyone seen something like this in their apps?

+7
source share
2 answers

I have never tracked the exact cause of this problem, but based on my experience in developing the corresponding application, I believe that this was caused by the impact of the memory limit for this activity. After you have finished the work, it seems that all kinds of strange errors can happen, including such things.

When I made other improvements in memory management of applications (in particular, using SoftReference with bitmaps), these types of exceptions begin to appear less often.

+2
source

I think Android 1.5 runs on these devices.

From the Docs on "Ensuring Better Device Compatibility with Resources" :

Providing default resources is important not only because the application may work in a configuration that you did not expect, but also because newer versions of Android sometimes add configurations that older versions do not support. If you use the new resource qualifier, but keep the code compatible with older versions of Android, then when the older version of Android launches your application, it will fail if you do not provide default resources because it cannot use the resources named in the new qualifier. For example, if your minSdkVersion is set to 4, and you have your available resources in night mode (night or night, have been added to API level 8), then a level 4 device cannot access your resource resources and fail. In this case, you probably do not want your resources to be unavailable by default, so you should exclude this qualifier so that your resources are either stretchable or we draw night /.

Since you use -hdpi -qualifier, this can be a problem, because those that are present in Android 1.6 (API level 4) and therefore not available in Android 1.5

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

Thus, providing some backup resources in the res/drawable may solve your problem.


There, the seams will be an error based on my original idea, which is described here: NotFoundException and FileNotFoundException when running the application on Android 1.5

This means that an error occurs for the next resource. Therefore, do not forget to provide a backup copy for each available in the res/drawable .

This applies to Android 1.5, I'm not sure if this is still a problem in Android 2.3, but that means that different manufacturers handle these things differently.

0
source

All Articles