When trying to build for an android game, I get "Failed to re-package resources. See the Console for details."

When attempting to build a simple game/test for android, I get the error “Failed to re-package resources. See the Console for details.” Below are the error messages from the console. Also, I did a google search, but all of the errors were about Google Play services, yet this should have nothing to do with it.

Here is a download file for the project if necessary: Controller Revolution

CommandInvokationFailure: Failed to
re-package resources. See the Console
for details.
C:\Users\chari\AppData\Local\Android\sdk\build-tools\24.0.0\aapt.exe
package --auto-add-overlay -v -f -m -J
gen -M AndroidManifest.xml -S “res” -I
“C:/Users/chari/AppData/Local/Android/sdk\platforms\android-23\android.jar”
-F bin/resources.ap_

stderr[

] stdout[

] UnityEditor.Android.Command.Run
(System.Diagnostics.ProcessStartInfo
psi,
UnityEditor.Android.WaitingForProcessToExit
waitingForProcessToExit, System.String
errorMsg)
UnityEditor.Android.PostProcessAndroidPlayer.Exec
(System.String command, System.String
args, System.String workingdir,
System.String progress_strings,
Single progress_value, System.String
errorMsg)
UnityEditor.Android.PostProcessAndroidPlayer.CompileResources
(System.String stagingArea,
System.String packageName,
UnityEditor.Android.AndroidLibraries
androidLibraries)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcessInternal
(System.String stagingAreaData,
System.String stagingArea,
System.String playerPackage,
System.String installPath,
System.String companyName,
System.String productName,
BuildOptions options,
UnityEditor.RuntimeClassRegistry
usedClassRegistry)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess
(BuildTarget target, System.String
stagingAreaData, System.String
stagingArea, System.String
playerPackage, System.String
installPath, System.String
companyName, System.String
productName, BuildOptions options,
UnityEditor.RuntimeClassRegistry
usedClassRegistry)
UnityEditor.HostView:OnGUI()
.
CommandInvokationFailure: Failed to
re-package resources. See the Console
for details.
C:\Users\chari\AppData\Local\Android\sdk\build-tools\24.0.0\aapt.exe
package --auto-add-overlay -v -f -m -J
gen -M AndroidManifest.xml -S “res” -I
“C:/Users/chari/AppData/Local/Android/sdk\platforms\android-23\android.jar”
-F bin/resources.ap_

stderr[

] stdout[

] UnityEditor.Android.Command.Run
(System.Diagnostics.ProcessStartInfo
psi,
UnityEditor.Android.WaitingForProcessToExit
waitingForProcessToExit, System.String
errorMsg)
UnityEditor.Android.PostProcessAndroidPlayer.Exec
(System.String command, System.String
args, System.String workingdir,
System.String progress_strings,
Single progress_value, System.String
errorMsg)
UnityEditor.Android.PostProcessAndroidPlayer.CompileResources
(System.String stagingArea,
System.String packageName,
UnityEditor.Android.AndroidLibraries
androidLibraries)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcessInternal
(System.String stagingAreaData,
System.String stagingArea,
System.String playerPackage,
System.String installPath,
System.String companyName,
System.String productName,
BuildOptions options,
UnityEditor.RuntimeClassRegistry
usedClassRegistry)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess
(BuildTarget target, System.String
stagingAreaData, System.String
stagingArea, System.String
playerPackage, System.String
installPath, System.String
companyName, System.String
productName, BuildOptions options,
UnityEditor.RuntimeClassRegistry
usedClassRegistry)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
.
Error building Player:
CommandInvokationFailure: Failed to
re-package resources. See the Console
for details.
C:\Users\chari\AppData\Local\Android\sdk\build-tools\24.0.0\aapt.exe
package --auto-add-overlay -v -f -m -J
gen -M AndroidManifest.xml -S “res” -I
“C:/Users/chari/AppData/Local/Android/sdk\platforms\android-23\android.jar”
-F bin/resources.ap_

stderr[

] stdout[

]

Unity is running aapt.exe from build-tools/24.0.0 ( you can see the path of aapt.exe in the log).
Version 24 is for Android N (the next upcoming version Android), which is not supported by Unity at the moment (many developers are complaining about this exact issue).

In order to resolve this issue, you have a few different options:

  • Under your Android SDK folder, remove version 24.0.0 of build-tools (sdk/build-tools/24.0.0).
  • You can do the same from the Android SDK manager (select build tools version 24 and then “delete package”)

  • In case you need that version specifically, you can install another Android SDK that will only be used with Unity. In this installation, do not include build-tools 24.

Lastly, you should try to upgrade to the latest Unity version, as this issue should be solved (I believe it was solved in 5.3.5p4).

NOTE: In some cases, it can get a bit tricky to find out why the build fails. If all else fails, I offer a service on Fiverr to help fix Android related build issues (due to manifest merging, conflicting plugins, etc). Check it out if you’re unable to resolve your issues !