IgoR IgoR - 4 months ago 183
Android Question

Unity3D - Failed to re-package resources | Android APK

I'm trying to compile a simple game without any additional plugin, but I am facing the errors below:

CommandInvokationFailure: Failed to re-package resources. See the Console for details.
C:\Program Files (x86)\Android\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:/Program Files (x86)/Android/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()


Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
C:\Program Files (x86)\Android\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:/Program Files (x86)/Android/android-sdk\platforms\android-23\android.jar" -F bin/resources.ap_

stderr[

]
stdout[

]


I have the latest versions of the Android SDK and JDK (Image updated after Answer of @Programmer):

enter image description here

I do not include any plugin or Google service, what might be happening?

UnityVersion: 5.3.4f1 Personal

On Unity 5.4.0b15, We have another error:

UnityException: Build failure
Failed to re-package resources. See the Console for details.
UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message)
UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuildPointToConsole (System.String title, System.String message)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
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.Android.AndroidBuildPostprocessor.PostProcess (BuildPostProcessArgs args)
UnityEditor.PostprocessBuildPlayer.Postprocess (BuildTarget target, System.String installPath, System.String companyName, System.String productName, Int32 width, Int32 height, System.String downloadWebplayerUrl, System.String manualDownloadWebplayerUrl, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.BuildReporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:176)
UnityEditor.HostView:OnGUI()


Thank you in advance!

Answer

It could be the spaces in the Android SDK and NDK path. Unity's update logs always says that this problem is fixed but that is not true. It fails sometimes.

  1. Make sure that there are no spaces in your SDK and NDK path. So create a folder called AndroidSDK and AndroidNDK in the C directory.

  2. Copy your Android-sdk folder to the C:/AndroidSDK directory. Copy your Android-ndk to the C:/AndroidNDK folder.

Now, your SDK path should look like this:

C:/AndroidSDK/Android-sdk
C:/AndroidNDK/Android-ndk

No spaces more.

  1. Update your Android SDK and NDK paths in the Unity Editor.

If that fails, download Unity 5.4 beta.

EDIT:

Re-download SDK. Then Build the Project for Android, it will show an error and ask you to update SDK. click on the "Update Android SDK" buttom. Unity will Automatically update your SDK. Your SDK should then look like something below.

enter image description here

Comments