patridge patridge - 9 months ago 41
Android Question

"aapt.exe" exited with code 1 when building Mono for Android project

I put together a fairly simple Mono for Android application that does nothing more than play an "AndroidResource" MP3 in a background service (copied from Greg Shackles latest Visual Studio Magazine article on Background Services in MfA). I put the code together, with my own custom MP3 file, and tried to build it, only to get this lovely error.

"aapt.exe" exited with code 1

That is the only info in the error list and build output log.


Step 1: get more info

If you run across this error, hopefully, you will also run across a post from Jonathan Pryor replying to someone else with the same problem. The suggestion is to turn on more verbose logging from MSBuild to see if you get something useful out of those messages.

In the Visual Studio Options dialog, go to "Projects and Solutions" then "Build and Run". Switch the "MSBuild project build output verbosity" from "Minimal" to "Normal" and build your project again. After doing so, I got this message which was far more helpful. Apparently, resources cannot include anything but letters, numbers, periods, and underscores ([a-z0-9_.]).

MSBuild normal verbosity logging


Rename file within the required restrictions and build again.

While this error message may come up for far more situations than filename restriction issues, a filename change fixed this particular issue completely.