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.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 multiple HDPI devices, so that resource was fine there. Before building the final APK, I did a full clean/rebuild, and of course sent the APK out for internal testing. The fact that I get 1-2 exceptions like this per version instead of 10,000 would indicate that this resource is definitely packaged correctly for most users.
I'm completely stumped and unsure why it wouldn't load on certain phones. Has anyone seen something like this in their apps?
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.
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