J'ai cherché un peu, mais toutes les réponses sur l'exception est liée à des personnes chargeant la mauvaise police.TrueType ne parvient pas à charger dans nid d'abeilles Android
Cependant, j'essaie de charger une police TrueType. Cela fonctionne pour la majorité des appareils sur lesquels j'ai testé. Cependant, en essayant de charger sur la Tab 10.1 sous Android 3.1 ou EeePad en cours d'exécution 3.2 Je reçois l'exception suivante:
Caused by: java.lang.RuntimeException: native typeface cannot be made
La trace complète de la pile:
java.lang.RuntimeException: Unable to start activity ComponentInfo{se.healthyheroes.android.app/se.healthyheroes.android.app.LoginActivity}: java.lang.RuntimeException: native typeface cannot be made
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
at android.app.ActivityThread.access$500(ActivityThread.java:122)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4123)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: native typeface cannot be made
at android.graphics.Typeface.<init>(Typeface.java:147)
at android.graphics.Typeface.createFromAsset(Typeface.java:121)
at se.healthyheroes.android.app.LoginActivity.initViews(LoginActivity.java:154)
at se.healthyheroes.android.app.LoginActivity.onCreate(LoginActivity.java:94)
at android.app.Activity.performCreate(Activity.java:4397)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
... 11 more
java.lang.RuntimeException: native typeface cannot be made
at android.graphics.Typeface.<init>(Typeface.java:147)
at android.graphics.Typeface.createFromAsset(Typeface.java:121)
at se.healthyheroes.android.app.LoginActivity.initViews(LoginActivity.java:154)
at se.healthyheroes.android.app.LoginActivity.onCreate(LoginActivity.java:94)
at android.app.Activity.performCreate(Activity.java:4397)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
at android.app.ActivityThread.access$500(ActivityThread.java:122)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4123)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
Vous pourriez interroger sur la ligne 154 dans LoginActivity . La ligne est celle-ci:
Typeface tf =(Typeface.createFromAsset(getAssets(), "fonts/style_5784.ttf"));
La police se trouve sous « actifs/polices/style_5784.ttf » dans mon projet dans Eclipse. La chose vraiment étrange est que cela fonctionne sur tous les autres appareils, sauf en nid d'abeille.
Est-ce que quelqu'un a une idée de ce qui pourrait causer l'exception? La police peut-elle être cassée ou peut-être y a-t-il quelque chose d'aussi simple que le nom du fichier? La seule chose que j'ai réussi à comprendre en cherchant autour de ça est que ça pourrait être la police qui est cassée d'une manière ou d'une autre.
Ceci est un punt de ma part, donc ceci est un commentaire. Avez-vous essayé de convertir votre police au format OTF, puis de le charger? J'ai seulement chargé les polices OTF dans Android. Vous pouvez utiliser Fontforge, comme décrit dans sa FAQ: http://fontforge.sourceforge.net/faq.html –
@AsimIhsan Je vais essayer au moins. –