2011-08-23 71 views
2

我已经搜索了一下,但是异常的所有答案都与加载错误字体的人有关。TrueType无法在Android蜂巢中加载

但是,我正在尝试加载TrueType字体。它适用于我测试过的大多数设备。然而,试图上的Tab 10.1负荷运转的Android 3.1或的EeePad运行3.2我得到以下异常:

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项目位于“资产/字体/ style_5784.ttf”。 真奇怪的是,它可以在蜂窝以外的所有其他设备上工作。

有没有人有一个想法可能会导致异常?字体是否可以被破坏,或者可能有文件的名称那么简单?我通过搜索周围唯一能理解的地方就是它可能是某种程度上被破坏的字体。

+0

这是我的一部分,因此这是一条评论。你有没有尝试将字体转换为OTF格式,然后加载它?我只有在Android中加载过OTF字体。您可以使用Fontforge,如其常见问题中所述:http://fontforge.sourceforge.net/faq.html –

+0

@AsimIhsan我至少会试一试。 –

回答

0

进一步查看此错误后,它看起来不像字体名称引起的错误。该错误发生在本地代码内部,它最有可能在Honeycomb中更改,并且无法通过堆栈跟踪进行调试。

直到源代码被释放后,我们将无法再看到错误。

+0

是的。完成只是跳过该字体。 –