Resources $ NotFoundException for drawable exception - but does it exist?

I am starting to see an odd set of stack traces from the market crash reporting interface. I am told that a resource that cannot be used does not exist. Xml in question:

<ImageView android:layout_width="13dip" android:layout_height="12dip" android:src="@drawable/foo" /> 

causing

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.me.app/com.me.app.MyActivity}: android.view.InflateException: Binary XML file line #51: Error inflating class <unknown> ... Caused by: android.content.res.Resources$NotFoundException: File res/drawable-hdpi/foo.png from drawable resource ID #0x7f020166 at android.content.res.Resources.loadDrawable(Resources.java:1732) at android.content.res.TypedArray.getDrawable(TypedArray.java:601) at android.widget.ImageView.<init>(ImageView.java:118) at android.widget.ImageView.<init>(ImageView.java:108) Caused by: java.io.FileNotFoundException: res/drawable-hdpi/foo.png at android.content.res.AssetManager.openNonAssetNative(Native Method) at android.content.res.AssetManager.openNonAsset(AssetManager.java:417) at android.content.res.Resources.loadDrawable(Resources.java:1724) 

Now "foo.png" exists both in the "drawable" and "drawable-hdpi" folders. I did not touch any of these drawings in age - I do not know why this error began to appear? It happens on various devices, Droids, Nexus Ones, etc.

thanks

+6
source share
2 answers

Try placing foo.png in another accessible folder, i.e. mdpi, xhdpi and xxhdpi. Maybe this can help.

+2
source

You can try the following methods:

1- If you work in Eclipse, try "Project Clean" from the debug menu. If you are in Intellij, try the β€œForm” project.

2- Delete and read the resource foo.png. after uninstalling, try restoring R and then reading.

3- Rename foo.png to something else and see how it works.

4- Try to delete the R file, because it is automatically generated and may solve your problem.

As far as I know, the problem is with the R file of your project.

0
source

Source: https://habr.com/ru/post/898696/


All Articles