CommandInvokationFailure: Failed to re-package resources

I’ve just recently began development for the Gear VR on Unity 5, and after creating my scene, which is just a basic room with the cameras, I get the error “Failed to re-package resources”. I tried some of the methods listed in other threads here, but to no avail. Any help would be appreciated. Here’s the error codes:

CommandInvokationFailure: Failed to re-package resources. See the Console for details.
C:\Users\XXX\AppData\Local\Android\sdk\build-tools\24.0.0-preview\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "C:/Users/XXX/AppData/Local/Android/sdk\platforms\android-21\android.jar" -F bin/resources.ap_ --extra-packages com.oculus.Integration -S "C:\Users\Public\Documents\Unity Projects\New Unity Project\Temp\StagingArea\android-libraries\ovrplugin\res"

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()


Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
C:\Users\XXX\AppData\Local\Android\sdk\build-tools\24.0.0-preview\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "C:/Users/XXX/AppData/Local/Android/sdk\platforms\android-21\android.jar" -F bin/resources.ap_ --extra-packages com.oculus.Integration -S "C:\Users\Public\Documents\Unity Projects\New Unity Project\Temp\StagingArea\android-libraries\ovrplugin\res"

stderr[

]
stdout[

]

I got the same error. What it looks like is that Unity does not work well with the version “24.0.0-preview” of the Android SDK build tools.

Solution: 1.) Quit unity
2.) Make sure you have e.g. the version “23.0.0” of the Android build tools installed.
3.) Find the folder called “24.0.0-preview” in your android SDK and delete it. ( Or move it somewhere else to copy it back again once you’re “done” with your unity dev’ing and maybe want to use the latest Android SDK for other stuff.
4.) Restart unity, exporting.

This worked for me. It’s not a great solution, because you basically can’t use the latest Android SDK version…

I tried to find a place “in unity” where one could configure which SDK version to use, but couldn’t find that.

I haven’t filed a bug report yet, but maybe that’d be a good idea…

Thank you! It actually worked! Now. I can build my apks out, I really appreciate this, gonna get me on the way to developing my own apps! Thanks again!

Worked for me!! Unity 5.3.5 and deleted at this location C:\Users[user]\AppData\Local\Android\sdk\build-tools

After updating Unity to 5.3.5 I installed back all SDK versions till API 24 and 23 preview, NO ERRORS. Thanks to Unity team for useful update.

Worked like a charm !! :smiley: … And I was stuck with updating sdk , creating version.xml , replacing aapt.exe for the last week . wish I had found this thread sooner . Thnx …

check your plugin/android folder you may have some duplicate files with different version like : play-services-ads-lite-9.2.1 , play-services-ads-lite-10.2.1. delete one of them , it worked fine.

we have the same error with Unity and Android:

UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg

using the Android SDK21 and Unity 5