tags:

views:

170

answers:

1

Hi, I have the following layout in XML (splashscreen.xml):

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/frmLayout" android:layout_width="fill_parent"
   android:layout_height="fill_parent">
    <ImageView
       android:id="@+id/splash"
       android:src="@drawable/splash"
       android:layout_width="fill_parent" android:layout_height="fill_parent"
       android:scaleType="fitXY" />
</FrameLayout>

SplashScreen.java:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splashscreen);
    // more code...
}

When I try to execute it in Android 1.5 (executes correctly in all other versions) I get these errors:

08-16 19:24:04.569: ERROR/AndroidRuntime(1002): Uncaught handler: thread main exiting due to uncaught exception
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.project/com.project.SplashScreen}: android.view.InflateException: Binary XML file line #5: Error inflating class java.lang.reflect.Constructor
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.app.ActivityThread.access$1800(ActivityThread.java:112)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.os.Looper.loop(Looper.java:123)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.app.ActivityThread.main(ActivityThread.java:3948)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at java.lang.reflect.Method.invokeNative(Native Method)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at java.lang.reflect.Method.invoke(Method.java:521)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at dalvik.system.NativeStart.main(Native Method)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class java.lang.reflect.Constructor
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.view.LayoutInflater.createView(LayoutInflater.java:512)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:617)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:309)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.app.Activity.setContentView(Activity.java:1626)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at com.project.SplashScreen.onCreate(SplashScreen.java:34)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     ... 11 more
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): Caused by: java.lang.reflect.InvocationTargetException
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.widget.ImageView.<init>(ImageView.java:103)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at java.lang.reflect.Constructor.constructNative(Native Method)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.view.LayoutInflater.createView(LayoutInflater.java:499)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     ... 22 more
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/title_bar_shadow.9.png from drawable resource ID #0x7f020021
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.content.res.Resources.loadDrawable(Resources.java:1641)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.widget.ImageView.<init>(ImageView.java:113)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     ... 26 more
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): Caused by: java.io.FileNotFoundException: res/drawable/title_bar_shadow.9.png
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.content.res.AssetManager.openNonAssetNative(Native Method)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.content.res.AssetManager.openNonAsset(AssetManager.java:392)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     at android.content.res.Resources.loadDrawable(Resources.java:1634)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002):     ... 28 more
08-16 19:25:39.511: ERROR/AndroidRuntime(1045): Uncaught handler: thread main exiting due to uncaught exception

Line 5 corresponds to ImageView line. Do you have any idea why my program executes in all Android versions except 1.5?

Thanks!

+1  A: 

A couple of related threads: http://groups.google.com/group/android-developers/browse_thread/thread/2f10922ac233c6df/5f67d345da4f0ccc?show_docid=5f67d345da4f0ccc

http://stackoverflow.com/questions/2923823/android-2-2-sdk-breaks-compatibility-with-older-phones

http://stackoverflow.com/questions/1922697/not-understanding-how-to-use-different-density-images-for-1-6

Mayra
Thanks, I'll take a look and post my answer when I come up with the solution.
Menda
I realized that 1.5 doesn't support _drawable-Xdpi_ folders, so the solution was to create a _drawable_ folder, and put all content there.As I wanted to support other screen resolutions in versions >= 1.6 I created _drawable-hdpi-v4_ and _drawable-mdpi-v4_. It's important that you include the v4 at the end of the name if you want it to work.
Menda