简体   繁体   English

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

[英]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): 我拥有最新版本的Android SDK和JDK(在@Programmer的答案后更新图像):

在此处输入图片说明

I do not include any plugin or Google service, what might be happening? 我不包含任何插件或Google服务,可能会发生什么?

UnityVersion: 5.3.4f1 Personal UnityVersion:5.3.4f1个人

On Unity 5.4.0b15 , We have another error: 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()

Thank you in advance! 先感谢您!

It could be the spaces in the Android SDK and NDK path. 可能是Android SDK和NDK路径中的空格。 Unity's update logs always says that this problem is fixed but that is not true. Unity的更新日志始终表示此问题已解决,但事实并非如此。 It fails sometimes. 有时会失败。

  1. Make sure that there are no spaces in your SDK and NDK path. 确保您的SDK和NDK路径中没有空格。 So create a folder called AndroidSDK and AndroidNDK in the C directory. 因此,在C目录中创建一个名为AndroidSDKAndroidNDK的文件夹。

  2. Copy your Android-sdk folder to the C:/AndroidSDK directory. 将您的Android-sdk文件夹复制到C:/AndroidSDK目录。 Copy your Android-ndk to the C:/AndroidNDK folder . 将您的Android-ndk复制到C:/AndroidNDK folder

Now, your SDK path should look like this: 现在,您的SDK路径应如下所示:

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

No spaces more. 没有更多的空间。

  1. Update your Android SDK and NDK paths in the Unity Editor. 在Unity编辑器中更新您的Android SDK和NDK路径。

If that fails, download Unity 5.4 beta . 如果失败,请下载Unity 5.4 beta

EDIT : 编辑

Re-download SDK . 重新下载SDK Then Build the Project for Android, it will show an error and ask you to update SDK. 然后,为Android构建项目,它将显示一个错误,并要求您更新SDK。 click on the " Update Android SDK " buttom. 点击“ 更新Android SDK ”按钮。 Unity will Automatically update your SDK. Unity将自动更新您的SDK。 Your SDK should then look like something below. 然后,您的SDK应该如下所示。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM