Note that there are some explanatory texts on larger screens.

plurals
  1. PONotFoundException and FileNotFoundException when running app on Android 1.5
    primarykey
    data
    text
    <p>I'm trying to backport an android 1.6+ application to android 1.5.</p> <p>Following the advice here:</p> <ul> <li><a href="http://comments.gmane.org/gmane.comp.handhelds.android.devel/97051" rel="nofollow noreferrer">http://comments.gmane.org/gmane.comp.handhelds.android.devel/97051</a></li> <li><a href="http://groups.google.com/group/android-developers/browse_thread/thread/ff22f6e42a4a46d2/4201a20aaa23069d" rel="nofollow noreferrer">http://groups.google.com/group/android-developers/browse_thread/thread/ff22f6e42a4a46d2/4201a20aaa23069d</a></li> <li><a href="https://stackoverflow.com/questions/2923823/android-2-2-sdk-breaks-compatibility-with-older-phones">Android 2.2 SDK breaks compatibility with older phones</a></li> <li><a href="https://developer.android.com/guide/topics/resources/providing-resources.html#ScreenCompatibility" rel="nofollow noreferrer">https://developer.android.com/guide/topics/resources/providing-resources.html#ScreenCompatibility</a></li> </ul> <p>... I have done the following:</p> <ol> <li>Modify AndroidManifest.xml to set minSdkVersion to 3</li> <li>Move all of my files that were previously in drawable-mdpi/ to drawable/</li> <li>Rename drawable-hdpi/ to drawable-hdpi-v4/</li> </ol> <p>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.</p> <p>However, after I compile, install, and run the resulting binary on the 1.5 emulator, I get the following error:</p> <pre><code>E/AndroidRuntime( 1096): Caused by: java.lang.reflect.InvocationTargetException E/AndroidRuntime( 1096): at android.widget.ImageView.&lt;init&gt;(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.&lt;init&gt;(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 </code></pre> <p>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.</p> <p>Running the same binary works fine on 1.6.</p> <p>Why won't 1.5 devices see my res/drawable/bg.png image with this setup?</p> <p><strong>UPDATE:</strong> As described in <a href="https://developer.android.com/guide/topics/resources/providing-resources.html#ScreenCompatibility" rel="nofollow noreferrer">Providing screen resource compatibility for Android 1.5</a>, 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().</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload