在棒棒糖上找不到字体资源 helvetica.ttf [英] Font asset not found helvetica.ttf on lollipop

查看:20
本文介绍了在棒棒糖上找不到字体资源 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

这是引发错误的代码

    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 Studio,请确保您的资产文件夹位于 main 而非 res 下这对我有用

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天全站免登陆