Problème lors du passage de l'API 8 à l'API 5
Bonjour,
Je souhaite rendre mon application compatible avec le plus de smartphone possible.
À la base je visais Android 2.2 est supérieur, car elle contient des Panoramas en Flash et que Flash n'existe qu'a partir de 2.2, mais en fait l'application contient d'autres choses qui peuvent fonctionner à partir de l'API 5.
J'utilise des fonctions available since API level 5 :
onBackPressed()
Account
Donc je suis allé dans default.properties et j'ai mis :
J'ai créer un AVD qui avait comme target Android 2.0, mais lors le l'éxécution j'ai eu beaucoup d'avertissements et d'erreurs :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| 05-17 07:44:19.844: ERROR/AndroidRuntime(253): Uncaught handler: thread main exiting due to uncaught exception
05-17 07:44:19.913: ERROR/AndroidRuntime(253): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.accueil/com.accueil.SplashScreen}: android.view.InflateException: Binary XML file line #11: Error inflating class android.widget.ImageView
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2454)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.os.Handler.dispatchMessage(Handler.java:99)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.os.Looper.loop(Looper.java:123)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.app.ActivityThread.main(ActivityThread.java:4310)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at java.lang.reflect.Method.invokeNative(Native Method)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at java.lang.reflect.Method.invoke(Method.java:521)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at dalvik.system.NativeStart.main(Native Method)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class android.widget.ImageView
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.app.Activity.setContentView(Activity.java:1622)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at com.accueil.SplashScreen.onCreate(SplashScreen.java:16)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): ... 11 more
05-17 07:44:19.913: ERROR/AndroidRuntime(253): Caused by: java.lang.reflect.InvocationTargetException
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.widget.ImageView.<init>(ImageView.java:105)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at java.lang.reflect.Constructor.constructNative(Native Method)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): ... 22 more
05-17 07:44:19.913: ERROR/AndroidRuntime(253): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/shape_background.xml from drawable resource ID #0x7f02000a
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.content.res.Resources.loadDrawable(Resources.java:1693)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.widget.ImageView.<init>(ImageView.java:115)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): ... 26 more
05-17 07:44:19.913: ERROR/AndroidRuntime(253): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/shape_background.xml from xml type drawable resource ID #0x7f02000a
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1912)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.content.res.Resources.loadDrawable(Resources.java:1688)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): ... 28 more
05-17 07:44:19.913: ERROR/AndroidRuntime(253): Caused by: java.io.FileNotFoundException: res/drawable/shape_background.xml
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.content.res.AssetManager.openXmlAssetNative(Native Method)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:470)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1894)
05-17 07:44:19.913: ERROR/AndroidRuntime(253): ... 29 more |
En fait là je lance une Activity qui ne fait que :
Code:
setContentView(R.layout.splash);
Le XML de la page c'est ça :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/shape_background" >
<ImageView
android:src="@drawable/logo_big"
android:layout_width="200dip"
android:layout_height="200dip"
android:layout_centerInParent="true"/>
</RelativeLayout> |
shape_background c'est ça :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| <?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:startColor="#77cdf4"
android:endColor="#b2ddf1"
android:angle="270"
dither="true"/>
<corners android:radius="0dp" />
</shape> |
J'ai regardé, et background et shape c'est depuis l'API 1.
Mais j'ai quand même viré tout ça pour le test.
Et j'ai les erreurs suivantes :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| 05-17 07:59:39.224: ERROR/AndroidRuntime(305): Uncaught handler: thread main exiting due to uncaught exception
05-17 07:59:39.275: ERROR/AndroidRuntime(305): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.accueil/com.accueil.SplashScreen}: android.view.InflateException: Binary XML file line #8: Error inflating class android.widget.ImageView
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2454)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.os.Handler.dispatchMessage(Handler.java:99)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.os.Looper.loop(Looper.java:123)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.app.ActivityThread.main(ActivityThread.java:4310)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at java.lang.reflect.Method.invokeNative(Native Method)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at java.lang.reflect.Method.invoke(Method.java:521)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at dalvik.system.NativeStart.main(Native Method)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class android.widget.ImageView
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.app.Activity.setContentView(Activity.java:1622)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at com.accueil.SplashScreen.onCreate(SplashScreen.java:16)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): ... 11 more
05-17 07:59:39.275: ERROR/AndroidRuntime(305): Caused by: java.lang.reflect.InvocationTargetException
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.widget.ImageView.<init>(ImageView.java:105)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at java.lang.reflect.Constructor.constructNative(Native Method)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): ... 22 more
05-17 07:59:39.275: ERROR/AndroidRuntime(305): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02000a a=-1 r=0x7f02000a}
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.content.res.Resources.loadDrawable(Resources.java:1677)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): at android.widget.ImageView.<init>(ImageView.java:115)
05-17 07:59:39.275: ERROR/AndroidRuntime(305): ... 26 more |
Donc voilà si vous avez une idée de la source de l'erreur, merci de m'en faire part.
L'application fonctionne parfaitement avec des téléphones sous Android 2.1 et supérieur.
Edit :
Dans /res/ j'ai un dossier drawable et un dossier drawable-nodpi, je devrais essayer de virer drawable-nodpi.
Re edit :
Ça marche.
Bon ben vous saurez que drawable-nodpi ça fait chier avant l'API 6.