Android - 构建播放器时出错:CommandInvokationFailure:无法重新打包资源

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25348615/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 09:21:46  来源:igfitidea点击:

Android - Error building Player: CommandInvokationFailure: Failed to re-package resources

androidunity3d

提问by NabeelSaleem

I am getting this error when i try to build my game for android. But it successfully built to webplayer. i checked everything is right,
and one think recently i upgrade my unity to 4.5.1

当我尝试为 android 构建我的游戏时出现此错误。但它成功构建到网络播放器。我检查一切正常,
有人认为最近我将我的 unity 升级到 4.5.1

Error details are:

错误详情是:

Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
D:\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20131030\sdk\build-tools\android-4.4\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "D:/adt-bundle-windows-x86_64-20131030/adt-bundle-windows-x86_64-20131030/sdk/platforms/android-18\android.jar" -F bin/resources.ap_

stderr[
AndroidManifest.xml:9: error: Error: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').
]
stdout[
Configurations:
 (default)
 hdpi
 ldpi
 xhdpi
 xxhdpi

Files:
  drawable\app_icon.png
    Src: () res\drawable\app_icon.png
    Src: (hdpi) res\drawable-hdpi\app_icon.png
    Src: (ldpi) res\drawable-ldpi\app_icon.png
    Src: (xhdpi) res\drawable-xhdpi\app_icon.png
    Src: (xxhdpi) res\drawable-xxhdpi\app_icon.png
  values\strings.xml
    Src: () res\values\strings.xml
  AndroidManifest.xml
    Src: () AndroidManifest.xml

Resource Dirs:
  Type drawable
    drawable\app_icon.png
      Src: () res\drawable\app_icon.png
      Src: (hdpi) res\drawable-hdpi\app_icon.png
      Src: (ldpi) res\drawable-ldpi\app_icon.png
      Src: (xhdpi) res\drawable-xhdpi\app_icon.png
      Src: (xxhdpi) res\drawable-xxhdpi\app_icon.png
  Type values
    values\strings.xml
      Src: () res\values\strings.xml
Including resources from package: D:\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20131030\sdk\platforms\android-18\android.jar
applyFileOverlay for drawable
applyFileOverlay for layout
applyFileOverlay for anim
applyFileOverlay for animator
applyFileOverlay for interpolator
applyFileOverlay for transition
applyFileOverlay for xml
applyFileOverlay for raw
applyFileOverlay for color
applyFileOverlay for menu
applyFileOverlay for mipmap
Processing image: res\drawable-hdpi\app_icon.png
Processing image: res\drawable\app_icon.png
    (processed image res\drawable\app_icon.png: 97% size of source)
Processing image: res\drawable-ldpi\app_icon.png
    (processed image res\drawable-ldpi\app_icon.png: 98% size of source)
Processing image: res\drawable-xhdpi\app_icon.png
    (processed image res\drawable-hdpi\app_icon.png: 98% size of source)
Processing image: res\drawable-xxhdpi\app_icon.png
    (processed image res\drawable-xhdpi\app_icon.png: 98% size of source)
    (processed image res\drawable-xxhdpi\app_icon.png: 98% size of source)
    (new resource id app_icon from drawable\app_icon.png #generated)
    (new resource id app_icon from hdpi\drawable\app_icon.png #generated)
    (new resource id app_icon from ldpi\drawable\app_icon.png #generated)
    (new resource id app_icon from xhdpi\drawable\app_icon.png #generated)
    (new resource id app_icon from xxhdpi\drawable\app_icon.png #generated)
]

回答by Maciej Fra?

I deleted the 24.0.0 build tools folder from Android\sdk\build-tools and it's working !

我从 Android\sdk\build-tools 中删除了 24.0.0 构建工具文件夹,它正在工作!

回答by Angel Duarte

You need to put the google_play_service_lib folder from the androidsdk\extra\google folder in plugins\android in order to make it work properly.

您需要将 androidsdk\extra\google 文件夹中的 google_play_service_lib 文件夹放在 plugins\android 中才能使其正常工作。

You can find it in android-sdk-windows\extras\google\google_play_services\libproject. There you will find google_play_service_lib. You copy it in plugins/android in unity

您可以在 android-sdk-windows\extras\google\google_play_services\libproject 中找到它。在那里你会找到 google_play_service_lib。您将其统一复制到 plugins/android 中

Credit to Ouss.

归功于奥斯。

note: if it's already in there, then chances are you've updated the android sdk, so you need the new lib folder. Close out of unity > delete the google play services lib folder > go to you sdk folder listed above > copy the lib folder in the address above > go back to your android plugins folder in your unity app > paste it in there > reopen unity and allow the scripts to compile > build.

注意:如果它已经在那里,那么你可能已经更新了 android sdk,所以你需要新的 lib 文件夹。关闭统一 > 删除谷歌播放服务 lib 文件夹 > 转到上面列出的 sdk 文件夹 > 复制上面地址中的 lib 文件夹 > 返回到你的统一应用程序中的 android 插件文件夹 > 将其粘贴到那里 > 重新打开统一和允许脚本编译>构建。

回答by Tino

There is a new problem out there. In case you installed the Android preview SDK 24.0.0 (if you have such a folder inside the build tools folder) then unity does not build / repackage properly.

那里有一个新问题。如果您安装了 Android 预览版 SDK 24.0.0(如果您在构建工具文件夹中有这样的文件夹),则 unity 无法正确构建/重新打包。

I see this issue:

我看到这个问题:

CommandInvokationFailure: Failed to re-package resources. See the Console for details.
C:\android-sdk\build-tools.0.0-preview\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "C:/android-sdk\platforms\android-23\android.jar" -F bin/resources.ap_ --extra-packages android.support.v7.appcompat:com.everyplay.Everyplay:com.google.example.games.mainlibproj:com.google.android.gms.base:com.google.android.gms:com.google.android.gms.drive:com.google.android.gms.games:com.google.android.gms.nearby:com.google.android.gms.plus:android.support.v4 -S "C:\Workspace\Spacegame\Temp\StagingArea\android-libraries\appcompat-v7-23.1.1\res" -S "C:\Workspace\Spacegame\Temp\StagingArea\android-libraries\everyplay\res" -S "C:\Workspace\Spacegame\Temp\StagingArea\android-libraries\play-services-base-8.4.0\res" -S "C:\Workspace\Spacegame\Temp\StagingArea\android-libraries\play-services-basement-8.4.0\res" -S "C:\Workspace\Spacegame\Temp\StagingArea\android-libraries\play-services-drive-8.4.0\res" -S "C:\Workspace\Spacegame\Temp\StagingArea\android-libraries\play-services-games-8.4.0\res" -S "C:\Workspace\Spacegame\Temp\StagingArea\android-libraries\play-services-nearby-8.4.0\res" -S "C:\Workspace\Spacegame\Temp\StagingArea\android-libraries\play-services-plus-8.4.0\res" -S "C:\Workspace\Spacegame\Temp\StagingArea\android-libraries\support-v4-23.1.1\res"

stderr[

]
stdout[
Configurations:
 (default)

Files:
  AndroidManifest.xml
    Src: () AndroidManifest.xml

Resource Dirs:
Including resources from package: C:\android-sdk\platforms\android-23\android.jar
applyFileOverlay for drawable
trying overlaySet Key=ic_plusone_medium_off_client.png
trying overlaySet Key=ic_plusone_small_off_client.png
trying overlaySet Key=ic_plusone_standard_off_client.png
trying overlaySet Key=ic_plusone_tall_off_client.png
trying overlaySet Key=common_full_open_on_phone.png
trying overlaySet Key=common_google_signin_btn_icon_dark.xml
trying overlaySet Key=common_google_signin_btn_icon_dark_disabled.9.png

The only working solution I found is to uninstall the 24.0.0 build tools folder - means simply delete it and restart Unity. Seems that Unity has issues with the new Android 24 build tools.

我找到的唯一可行的解​​决方案是卸载 24.0.0 构建工具文件夹 - 意味着只需将其删除并重新启动 Unity。似乎 Unity 对新的 Android 24 构建工具存在问题。

Edit: you'll find the build tools folder inside your Android SDK Folder

编辑:您将在 Android SDK 文件夹中找到构建工具文件夹

回答by NabeelSaleem

What i did and it worked.

我做了什么,它奏效了。

i had only jre not jdk. First i download jdk from oracle site.
set up environments path:

我只有jre没有jdk。首先我从oracle站点下载jdk。
设置环境路径:

JAVA_HOME
C:\Program Files (x86)\Java\jdk1.8.0_11\bin

JAVA_HOME
C:\Program Files (x86)\Java\jdk1.8.0_11\bin

but error exist again.

但错误再次存在。

========================================

========================================

Then i got this guide: try this and tell if it works.

然后我得到了这个指南:试试这个,看看它是否有效。

copy zipalign.exe file from > D:\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\build-tools\android-4.4W

复制 zipalign.exe 文件 > D:\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\build-tools\android

or where ever you have it and then Past to > D:\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\tools

或者你有它的地方,然后粘贴到 > D:\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\tools

Unity3diy forums

Unity3diy 论坛

And everything works perfect :)

一切都很完美:)