Error:Error: Expected resource of type raw [ResourceType]

今天学习程序签名打包,就把之前传到github上得扣丁音乐打包,试了下,报了这个错误


Error:Error: Expected resource of type raw [ResourceType]


问题代码:

if(small){
    return BitmapFactory.decodeStream(context.getResources().openRawResource(R.drawable.music_play),null,opts);
}
return BitmapFactory.decodeStream(context.getResources().openRawResource(R.drawable.music_play),null,opts);

修改参考:



12 down vote accepted

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);
我选择得是2,修贷后代码:


if(small){
    return BitmapFactory.decodeStream(context.getResources().openRawResource(+R.drawable.music_play),null,opts);
}
return BitmapFactory.decodeStream(context.getResources().openRawResource(+R.drawable.music_play),null,opts);

希望能给你带来帮助

你可能感兴趣的:(BUG天天见)