我搜索了一下,但异常的所有答案都与加载错误字体的人有关。
但是,我正在尝试加载TrueType字体。它适用于我测试过的大多数设备。但是,当尝试加载运行Android 3.1或运行3.2的EEEPad的Tab 10.1时,我得到以下异常:
Caused by: java.lang.RuntimeException: native typeface cannot be made
完整的堆栈跟踪:
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)
您可能想知道LoginActivity中的第154行。 这一行就是这个:
Typeface tf =(Typeface.createFromAsset(getAssets(), "fonts/style_5784.ttf"));
该字体位于Eclipse项目中的“assets / fonts / style_5784.ttf”下。 真正奇怪的是它适用于除蜂窝之外的所有其他设备。
有没有人知道什么可能导致异常?字体可能会被破坏,或者可能有一些像文件名一样简单的东西?我通过搜索它来设法理解的唯一一件事是它可能是以某种方式破坏的字体。
答案 0 :(得分:0)
进一步查看此错误后,看起来字体名称不会导致错误。错误发生在本机代码中,很可能在Honeycomb中发生了更改,无法通过堆栈跟踪进行调试。
在源已发布之前,我们将无法进一步查看错误。