Why am I getting this error "Expected resource of type raw" in Android Studio?
Replace
InputStream is = getResources().openRawResource(R.drawable.icon);
With
InputStream is = getResources().openRawResource(+ R.drawable.icon);
The error occurred because Android Studio expected a resource file of type raw.
Solution 1:
Create a new folder in your "res" folder called "raw", and put your icon there. The raw folder should contain all your media files of your app.
Then replace
InputStream is = getResources().openRawResource(R.drawable.icon);
with
InputStream is = getResources().openRawResource(R.raw.icon);
Solution 2:
Another solution is to do it like this. This doesn't require you to create a raw folder:
InputStream is = getResources().openRawResource(+ R.drawable.icon);