Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my app trying to use drawable-mdpi/title_bar_shadow.9.png?

The app works fine on HPDI and MDPI, but when run in an LDPI (v2.0) emulator, I get the exception and stack trace below.

Why is it looking for this image? (it's not referenced in my application, I've checked). The starter activity has disabled the title bar in any case.

If the OS expects this image, why is it not present?

Why is the exception relating to an MPDI image, when the emulator is LDPI?

04-20 11:35:19.432: ERROR/AndroidRuntime(236): Uncaught handler: thread main exiting due to uncaught exception
04-20 11:35:19.502: ERROR/AndroidRuntime(236): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.spondle/com.spondle.EventsActivity}: android.view.InflateException: Binary XML file line #14: Error inflating class <unknown>
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2454)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)
        at android.app.ActivityThread.access$2200(ActivityThread.java:119)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:123)
        at android.app.ActivityThread.main(ActivityThread.java:4310)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:521)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
        at dalvik.system.NativeStart.main(Native Method)
        Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class <unknown>
        at android.view.LayoutInflater.createView(LayoutInflater.java:513)
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
        at android.app.Activity.setContentView(Activity.java:1622)
        at com.spondle.EventsActivity.onCreate(EventsActivity.java:38)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
        ... 11 more
        Caused by: java.lang.reflect.InvocationTargetException
        at android.widget.ImageView.<init>(ImageView.java:105)
        at java.lang.reflect.Constructor.constructNative(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
        at android.view.LayoutInflater.createView(LayoutInflater.java:500)
        ... 23 more
        Caused by: android.content.res.Resources$NotFoundException: File res/drawable-mdpi/title_bar_shadow.9.png from drawable resource ID #0x7f02002a
        at android.content.res.Resources.loadDrawable(Resources.java:1710)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
        at android.widget.ImageView.<init>(ImageView.java:115)
        ... 27 more
        Caused by: java.io.FileNotFoundException: res/drawable-mdpi/title_bar_shadow.9.png
        at android.content.res.AssetManager.openNonAssetNative(Native Method)
        at android.content.res.AssetManager.openNonAsset(AssetManager.java:391)
        at android.content.res.Resources.loadDrawable(Resources.java:1702)
        ... 29 more
like image 255
Ollie C Avatar asked Apr 20 '11 11:04

Ollie C


2 Answers

If the OS expects this image, why is it not present?

Why is the exception relating to an MPDI image, when the emulator is LDPI?

If the requested resource (title_bar_shadow.9.png) is not present in drawable-ldpi (and it wasn't until Android 2.3), Android will try to find the best match (drawable-mdpi will be the next folder to search in). Anyway, the file will not be found there either (again, it was not there until Android 2.3). So the next step would be to search for it in drawable-hdpi (where it can be found). But apparently the search stops on drawable-mdpi (which is strange... maybe a bug in Android 2.1? you could try Android 2.2 emulator)

Why is it looking for this image? (it's not referenced in my application, I've checked). The starter activity has disabled the title bar in any case.

This image (shadow) is not used by the title bar. It is displayed UNDER the title bar. To make it disappear, you have to create your own theme, like this:

<style
  name="Theme"
  parent="android:Theme.NoTitleBar">
  <item
    name="android:windowContentOverlay">@null</item>
</style>
like image 121
Edi Avatar answered Nov 15 '22 05:11

Edi


I solved this problem making a copy of the images from drawable-ldpi/mdip/hdpi to a drawable (only drawable) folder. Put in this folder your low resolution images.

You don't need to have a title_bar_shadow.9.png file on these folders.

like image 31
Derzu Avatar answered Nov 15 '22 05:11

Derzu