Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding audio files to Android resources

Tags:

android

I added a few mp3 files (eg, bells.mp3) to a 'raw' folder under 'res'. However, when I do this:

mp = MediaPlayer(this,R.raw.bells);

it complains that 'raw' cannot be resolved. Is there something more I need to do to make these resources available?

like image 620
Richard Eng Avatar asked Nov 26 '22 05:11

Richard Eng


1 Answers

Please make sure that you are importing R from your project not the android one

Example:

import com.example.myProject.R;

not this one

import android.R;
like image 143
Adel Refaat Avatar answered Jun 23 '23 07:06

Adel Refaat