Unity3D - 无法重新打包资源| Android APK

时间:2016-04-26 02:56:19

标签: android unity3d compilation apk android-sdk-tools

我正在尝试编译一个没有任何额外插件的简单游戏,但我面临以下错误:

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[

]

我有最新版本的Android SDK和JDK(图片在@Programmer回答后更新):

enter image description here

我不包含任何插件或Google服务,可能会发生什么?

UnityVersion:5.3.4f1个人

Unity 5.4.0b15 上,我们还有另一个错误:

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

提前谢谢!

1 个答案:

答案 0 :(得分:3)

它可能是Android SDK和NDK路径中的空格。 Unity的更新日志总是说这个问题是固定的,但事实并非如此。它有时会失败。

  1. 确保SDK和NDK路径中有空格。因此,在C目录中创建一个名为AndroidSDKAndroidNDK的文件夹。

  2. Android-sdk文件夹复制到C:/AndroidSDK目录。将Android-ndk复制到C:/AndroidNDK folder

  3. 现在,您的SDK路径应如下所示:

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

    没有空位。

    1. 在Unity编辑器中更新Android SDK和NDK路径。
    2. 如果失败,请下载Unity 5.4 beta

      修改

      重新下载SDK。然后为Android构建项目,它将显示错误并要求您更新SDK。点击“更新Android SDK ”按钮。 Unity将自动更新您的SDK。您的SDK应该如下所示。

      enter image description here