app crash due to android.content.res.Resources$NotFoundException:

Viewed 68

I made my app and it work well in emulator and many actual device.

Recently, I checked crash report on Google play console and found crash report "Caused by: android.content.res.Resources$NotFoundException" as in below picture:

crash picture

I thought this cause by my Logo.java have issue. below is my Logo.java code:

 @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();


}

I don't know why some device have this crash. Can anyone please help me solve this problem?

1 Answers

Instead of using ResourcesCompat.getFont, you can just use getFont(int fontIdentifier). That will do the task for you

Related