'app crash due to android.content.res.Resources$NotFoundException:
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:
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?
Solution 1:[1]
Instead of using ResourcesCompat.getFont, you can just use getFont(int fontIdentifier).
That will do the task for you
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sambhav. K |
