不能在统一java插件上使用google play服务

Dim*_*ima 7 plugins android unity-game-engine google-play-services

我有一个用Java编写的Unity插件.在这个插件中,我需要获取新的Google 广告ID才能执行此操作,我必须添加到Manifest文件中:

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
Run Code Online (Sandbox Code Playgroud)

当我编译时,Unity会抛出错误:

Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
/Applications/adt/sdk/build-tools/android-4.2.2/aapt package --auto-add-overlay -v -f -m -  J gen -M AndroidManifest.xml -S "res" -I "/Applications/adt/sdk/platforms/android-  19/android.jar" -F bin/resources.ap_

stderr[
AndroidManifest.xml:21: error: Error: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').
]
Run Code Online (Sandbox Code Playgroud)

我还尝试将Google Play服务jar添加到[lugins/Androif文件夹但是没有帮助.使它运作的正确方法是什么?

jab*_*jab 25

要修复此错误,您必须将version.xml文件复制android-sdk/extras/google/google_play_services/libproject/google-play-services_lib/res/values/Assets/Plugins/Android/res/values/Unity项目的文件夹中.


Mar*_*ski -1

您需要将最新的 Google Play 服务库项目链接到您的项目,因此在构建期间,该项目中的所有资源也将可用。您肯定拥有较旧的库,因为google_play_services_version最近才推出。而且你不能只是添加jar到你的项目中——它不会起作用。只需按照文档添加 Google Play 服务作为永久库即可。