Build Fails with "Failed to re-package resources"

When I attempt to build a project to Android, I get the following error:

Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details. C:\Users\ALec\AppData\Local\Android\android-sdk\build-tools\21.0.1\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "C:/Users/ALec/AppData/Local/Android/android-sdk/platforms/android-21\android.jar" -F bin/resources.ap_ --extra-packages -S "C:\Users\ALec\Games\Zylum\Zylum Unity Project\Temp\StagingArea\android-libraries\google-play-services_lib\res

The error continues, but I think this is the most relevant part. I’m not certain what’s going on.


When I tried to build this morning, Unity failed with a slightly different error: Refresh: detecting if any assets need to be imported or removed ... Refresh: ela -

Check to see if you have the top two variables in your user variables under environment variables: JAVA_HOME and PATH. If not, add these variables with the path to your java location and its bin folder. If it is correct, it should look similar to the picture below.

Just this morning I saw same question on stackoverflow
So here it is

Version 21+ of the Android SDK Build-tools does not seem to work.
Using the SDK Manager, downgrade to Version 20 and that should fix
your issue.

– Thanks toTerrell Stephen

question on stackoverflow

Please update your build-tools to version 21.0.2 released this morning:

Also more info is on the forums:

I figured it out!! It turns out that the Chartboost plugin needs to re-run “setup android SDK” after updating. Weird, though, that the error was so un-descriptive. Thanks again for all your help guys!

The issue is related to JDK. Please update the JDK and make sure it is installed completely and correctly.