应用程序崩溃由于android.content.res.Resources$NotFoundException:.<



我制作了我的应用程序,它在模拟器和许多实际设备上运行良好。

最近,我检查了Google play控制台的崩溃报告,发现崩溃报告"由:android.content.res.Resources$NotFoundException"如下图所示:

事故图片

我认为这是由于我的Logo.java有问题。下面是我的Logo.java代码:

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_logo);
txtappname = findViewById(R.id.txtappname);
Typeface typeface = ResourcesCompat.getFont(this,R.font.kaushan_script);
txtappname.setTypeface(typeface);
Animation animation = AnimationUtils.loadAnimation(this,R.anim.appanim);
txtappname.setAnimation(animation);
new Thread(){
@Override
public void run(){
try {
sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
startActivity(new Intent(Logo.this,ListeningTab.class));
}

}.start();

}

我不知道为什么有些设备会崩溃。有人能帮我解决这个问题吗?

不使用ResourcesCompat.getFont,只使用getFont(int fontIdentifier)即可。这将为你完成这项任务

相关内容