Caused by: java.lang.RuntimeException: Font asset not found fonts/SYFZLTKHJW.TTF

    /**
     * 通过反射方法设置app全局字体
     */
    public void setTypeface() {
        typeFace = Typeface.createFromAsset(getAssets(), "fonts/SYFZLTKHJW.TTF");
        try {
            Field field = Typeface.class.getDeclaredField("SERIF");
            field.setAccessible(true);
            field.set(null, typeFace);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }




08-22 18:50:22.778 27533-27533/com.moreunion.zhenghao E/AndroidRuntime: FATAL EXCEPTION: main
                                                                        Process: com.moreunion.zhenghao, PID: 27533
                                                                        java.lang.RuntimeException: Unable to create application com.moreunion.zhenghao.app.BaseApplication: java.lang.RuntimeException: Font asset not found fonts/SYFZLTKHJW.TTF
                                                                            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5678)
                                                                            at android.app.ActivityThread.-wrap2(ActivityThread.java)
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637)
                                                                            at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                            at android.os.Looper.loop(Looper.java:156)
                                                                            at android.app.ActivityThread.main(ActivityThread.java:6524)
                                                                            at java.lang.reflect.Method.invoke(Native Method)
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
                                                                         Caused by: java.lang.RuntimeException: Font asset not found fonts/SYFZLTKHJW.TTF
                                                                            at android.graphics.Typeface.createFromAsset(Typeface.java:228)
                                                                            at com.moreunion.zhenghao.app.BaseApplication.setTypeface(BaseApplication.java:121)
                                                                            at com.moreunion.zhenghao.app.BaseApplication.onCreate(BaseApplication.java:34)
                                                                            at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1028)
                                                                            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5659)
                                                                            at android.app.ActivityThread.-wrap2(ActivityThread.java) 
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637) 
                                                                            at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                            at android.os.Looper.loop(Looper.java:156) 
                                                                            at android.app.ActivityThread.main(ActivityThread.java:6524) 
                                                                            at java.lang.reflect.Method.invoke(Native Method) 
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941) 
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831) 


原因:

没有添加assets/fonts/SYFZLTKHJW.TTF文件


你可能感兴趣的:(Android)