R.drawable cannot resolve image

I checked a lot of questions about stackoverflow, and I seem to have all the right things, but my R.drawable will not detect my image. It is located in / res / drawable and in all other folders (mdpi, hdpi, etc.)

ShipImage = context.getResources().getDrawable(R.drawable.player); 

And here is my R.java

  public static final class drawable { public static final int background=0x7f020000; public static final int buttons=0x7f020001; public static final int dead=0x7f020002; public static final int enemy=0x7f020003; public static final int ic_launcher=0x7f020004; public static final int play_btn=0x7f020005; public static final int player=0x7f020006; } 
+6
source share
3 answers

Are you sure you are importing import com.yourcompanyname.product.R ?

instead

import android.R;

+23
source

import com.yourcompanyname.product.R is different from import android.R

First, your R project file, which is generated by the SDK.

import android.R is an embedded R file that is provided by Android.

+2
source

Make sure your image is png. Also check that you have saved the layout where you should inflate the image.

+1
source

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


All Articles