字体资产未发现helvetica.ttf的棒棒糖 [英] Font asset not found helvetica.ttf on lollipop

查看:771
本文介绍了字体资产未发现helvetica.ttf的棒棒糖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因在棒棒糖,我得到这个错误,因为棒棒糖太新了我无法找出原因的任何地方,我不知道如何计算出来。在此先感谢logcat的错误:

For some reason on lollipop, I'm getting this error and since lollipop is so new I can't find out why anywhere and I have no idea how to figure it out. Thanks in advance Logcat error:

java.lang.RuntimeException: Unable to start activity                                       
ComponentInfo{com.bent.MissionaryTracker/com.bent.MissionaryTracker.MainActivity}:          
java.lang.RuntimeException: Font asset not found helvetica.ttf
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.RuntimeException: Font asset not found helvetica.ttf
at android.graphics.Typeface.createFromAsset(Typeface.java:190)
at com.bent.MissionaryTracker.MainActivity.onCreate(MainActivity.java:57)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
... 10 more

编辑:这里是code,它引发错误

HERE IS THE CODE THAT THROWS THE ERROR

    title = (TextView) findViewById(R.id.title);


    Typeface font = Typeface.createFromAsset(getAssets(), "helvetica.ttf");
    title.setTypeface(font);

我有helvetica.ttf在我的资产文件夹在我的项目文件夹。

I have helvetica.ttf in my assets folder in my project folders.

编辑: 这个应用程序适用于所有的设备,直到5.0,以便由于某些原因5.0没有认识到我的资产文件夹中的文件。

This app works on all devices up until 5.0 so for some reason 5.0 is not recognizing the file in my assets folder.

我试图张贴它的截图在我的资产文件夹,但我没有足够的信誉发表图片。

I tried to post a screenshot of it in my assets folder but I don't have enough reputation to post images.

推荐答案

如果您正在使用Android的工作室,确保您的资产文件夹下的主,而不是资源 这为我工作。

If you are working on Android Studio make sure your asset folder is under main and not res This worked for me

这篇关于字体资产未发现helvetica.ttf的棒棒糖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆