Error: The file name must end with .xml or .png wh

2020-02-07 05:17发布

问题:

I'm using Gradle 1.5.0 with Android Studio. Project syncs with Gradle without any issues, but when I run the app, I get the follow error message

Error:Execution failed for task ':App:mergeDebugResources'.
/Users/Zee/Repos/App/res/drawable/notification.mp3: Error: The filename must end with .xml or .png

Using an mp3 file, so not sure what to do at this point. Any help is much appreciated.

回答1:

You can't put mp3 file in drawable. Drawable folder is for images. Put your mp3 file or any other format in raw folder.

Raw folder can be found in res/raw If it doesn't exist then just create a raw folder in res folder.



回答2:

Possible cause

Another scenario causing the error might be, that you must have mistakenly pasted your whole drawable-xxxhdpi/xxhdpi/xhdpi/hdpi/mdpi folder in your drawable folder which may have resulted in cascading of drawable folder and thus giving this error.

Solution

Just go to that folder & delete the unwanted/extra folders.Then the issue will get solved.



回答3:

Error:Execution failed for task ':App:mergeDebugResources'.
/Users/Zee/Repos/App/res/drawable/notification.mp3: Error: The filename must end with .xml or .png

this error occurrs when we attempt to delete all files except .xml and .png from all folders in our package.

e.g. If the assets folder has the files debug.exe and java.exe, and we want to delete them