32

I am beginner with Android Studio. I have an MP3 file in my res\raw folder. When I sync project with Gradle files. I get the following dialog box:

enter image description here

How do I allow for MP3 files in my project?

I read this: Register new file type in Android, but I'm not building an MP3 player. My intention is for the user to have an MP3 player currently installed on their device.

I also tried navigating to File -> Settings -> Plugins and searching for an MP3 player for Android Studio.

Should I just select Text files and move on?

I do not need Android Studio to play MP3 files.

Community
  • 1
  • 1
nu everest
  • 9,589
  • 12
  • 71
  • 90

8 Answers8

55

That window is just how you want Android studio to open the file so you can visualize/listen to the file. It does not affect how the file is handled by android at all.

Since Android Studio does not have a media player, I suggest you to select Open matching files in associated application That will launch your default music player and play that mp3.

Note: remember that all the files under res should ONLY contain lowercase letters, numbers and underscores. If you have your mp3 with the wrong name conditions will not compile.

Doug Richardson
  • 10,483
  • 6
  • 51
  • 77
Marcus Gabilheri
  • 1,259
  • 1
  • 14
  • 26
21

I decided to select Text files. This was a bad idea since opening the file results in encoded garbage output to the screen.

With help from this page. I went back to File -> Settings -> File Types -> Text files and removed *.mp3 from the Registered Patterns by clicking the red minus sign.

See this image: enter image description here

After this I clicked OK and re-synced the project with gradle. When this screen popped up again. I selected Open matching files in associated application. Now I do not get this pop-up and the mp3 opens in Windows Media Player if I double-click it.

enter image description here

nu everest
  • 9,589
  • 12
  • 71
  • 90
5
  1. Select File -> Settings -> File Types -> Files Opened In Associated Applications
  2. Click on the + sign
  3. Add "*.mp3"
  4. (If you have previously incorrectly associated "*.mp3" with something else, then Android Studio warns you and allows you to delete the old association)
  5. Click OK

File->Settings->File Types->Files Opened In Associated Applications->*.mp3

It does not matter how you want to use MP3 files in your project afterwards. Android Studio now knows how to open them in case you click on them.

Community
  • 1
  • 1
pintergabor
  • 428
  • 5
  • 8
2

This may not be an answer, but hope it'd be helpful to know that on Linux Mint Rebecca (based on Ubuntu 14.04), the problem is not reproduced.

Frank R.
  • 1,732
  • 18
  • 21
1

Kindly check the naming convention used for the file.It should be all lower case in the res folder. This will solve the problem.

If not select on "Open matching files in associated application".

0

This is a common error. Check whether your file is named in lower case --this is very important. Save file in text file format as showing in android Studio. Eventhough the icon is in text file in the raw folder, U will be able to hear the music on emulator or plugged in device.

0

Firstly check mp3 or mp4 file name. If you choosed Upper case letter for this video, you need to refactor it's name.

  • all the files under res/raw should only contain lowercase letters, numbers and underscores.
Emre Gürses
  • 1,992
  • 1
  • 23
  • 28
-1

I changed the ".mp3" to "m4a" of the music and it worked