I'm trying to backport an android 1.6+ application to android 1.5.
Following the advice here:
- http://comments.gmane.org/gmane.comp.handhelds.android.devel/97051
- http://groups.google.com/group/android-developers/browse_thread/thread/ff22f6e42a4a46d2/4201a20aaa23069d
- Android 2.2 SDK breaks compatibility with older phones
- https://developer.android.com/guide/topics/resources/providing-resources.html#ScreenCompatibility
... I have done the following:
- Modify AndroidManifest.xml to set minSdkVersion to 3
- Move all of my files that were previously in drawable-mdpi/ to drawable/
- Rename drawable-hdpi/ to drawable-hdpi-v4/
It seems to me that this should ensure that 1.5 devices use the files in drawable/ while 1.6 and later devices use the files in drawable/ and drawable-hdpi-v4/ as appropriate. The drawable/ and drawable-hdpi-v4/ directories are the only drawable directories in my res folder.
However, after I compile, install, and run the resulting binary on the 1.5 emulator, I get the following error:
E/AndroidRuntime( 1096): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 1096): at android.widget.ImageView.<init>(ImageView.java:103)
E/AndroidRuntime( 1096): at java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 1096): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
E/AndroidRuntime( 1096): at android.view.LayoutInflater.createView(LayoutInflater.java:499)
E/AndroidRuntime( 1096): ... 26 more
E/AndroidRuntime( 1096): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/bg.png from drawable resource ID #0x7f02002e
E/AndroidRuntime( 1096): at android.content.res.Resources.loadDrawable(Resources.java:1641)
E/AndroidRuntime( 1096): at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
E/AndroidRuntime( 1096): at android.widget.ImageView.<init>(ImageView.java:113)
E/AndroidRuntime( 1096): ... 30 more
E/AndroidRuntime( 1096): Caused by: java.io.FileNotFoundException: res/drawable/bg.png
E/AndroidRuntime( 1096): at android.content.res.AssetManager.openNonAssetNative(Native Method)
E/AndroidRuntime( 1096): at android.content.res.AssetManager.openNonAsset(AssetManager.java:392)
E/AndroidRuntime( 1096): at android.content.res.Resources.loadDrawable(Resources.java:1634)
E/AndroidRuntime( 1096): ... 32 more
For reasons I don't understand, 1.5 devices are not able to see the bg.png image file, a version of which is in both the drawable/ and drawable-hdpi-v4/ directories.
Running the same binary works fine on 1.6.
Why won't 1.5 devices see my res/drawable/bg.png image with this setup?
UPDATE: As described in Providing screen resource compatibility for Android 1.5, I'm using Android SDK r6 and have put my mdpi resources in the drawable/ directory. Also, I've verified that the problem isn't isolated to bg.png. If I remove the reference to the broken drawable in my xml, the app breaks on the next and each subsequent graphic during setContentView().