Android 添加 Google 广告中介时资源链接失败 (Unity)

Android resource linking failed when adding Google Ads mediation (Unity)

我在尝试构建 gradle 时遇到“Android 资源链接失败”错误。在我添加 Google 中介 SDK(它在没有中介的情况下与 GoogleMobileAds SDK 一起工作)之前,我没有遇到此错误,我尝试了强制解析,以及我可以在网上找到的所有其他内容。这肯定是中介 SDK。我尝试了一切,无论有没有,只要我导入任何一个 SDK,我就会收到这些错误。

我正在使用 Unity 2019.4.17f1,并按照建议安装了所有 Unity Android 模块。我使用了最新版本的中介 SDK 和 GoogleMobileAds SDK。

使用: Google 移动广告 v5.4.0, Facebook Unity 中介插件 3.1.0, Unity 广告中介插件 2.6.0

详细错误写在下面,还有我的控制台截图。

Task :unityLibrary:preBuild UP-TO-DATE Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:preBuild UP-TO-DATE Task :launcher:preBuild UP-TO-DATE Task :unityLibrary:preReleaseBuild UP-TO-DATE Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:preReleaseBuild UP-TO-DATE Task :unityLibrary:checkReleaseManifest UP-TO-DATE Task :launcher:prepareLintJar UP-TO-DATE Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:checkReleaseManifest Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:processReleaseManifest Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:compileReleaseAidl NO-SOURCE Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:packageReleaseRenderscript NO-SOURCE Task :unityLibrary:processReleaseManifest Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:compileReleaseRenderscript NO-SOURCE Task :unityLibrary:compileReleaseAidl NO-SOURCE Task :unityLibrary:packageReleaseRenderscript NO-SOURCE Task :unityLibrary:compileReleaseRenderscript NO-SOURCE Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE Task :unityLibrary:generateReleaseResValues UP-TO-DATE Task :unityLibrary:generateReleaseResources UP-TO-DATE Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:generateReleaseResValues Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:generateReleaseResources Task :unityLibrary:packageReleaseResources UP-TO-DATE Task :unityLibrary:prepareLintJar UP-TO-DATE Task :unityLibrary:generateReleaseSources UP-TO-DATE Task :unityLibrary:prepareLintJarForPublish UP-TO-DATE Task :unityLibrary:mergeReleaseShaders UP-TO-DATE Task :unityLibrary:compileReleaseShaders UP-TO-DATE Task :unityLibrary:generateReleaseAssets UP-TO-DATE Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:packageReleaseResources Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:generateReleaseRFile Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:generateReleaseBuildConfig Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:prepareLintJar UP-TO-DATE Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:generateReleaseSources Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:javaPreCompileRelease Task :unityLibrary:packageReleaseAssets Task :launcher:preReleaseBuild Task :launcher:compileReleaseAidl NO-SOURCE Task :launcher:compileReleaseRenderscript NO-SOURCE Task :launcher:checkReleaseManifest UP-TO-DATE Task :launcher:generateReleaseBuildConfig UP-TO-DATE Task :launcher:generateReleaseSources UP-TO-DATE Task :launcher:mainApkListPersistenceRelease UP-TO-DATE Task :launcher:generateReleaseResValues UP-TO-DATE Task :launcher:generateReleaseResources UP-TO-DATE Task :unityLibrary:generateReleaseRFile UP-TO-DATE Task :unityLibrary:processReleaseJavaRes NO-SOURCE Task :unityLibrary:mergeReleaseJniLibFolders UP-TO-DATE Task :unityLibrary:transformNativeLibsWithMergeJniLibsForRelease UP-TO-DATE Task :unityLibrary:transformNativeLibsWithStripDebugSymbolForRelease UP-TO-DATE Task :launcher:mergeReleaseResources UP-TO-DATE Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE Task :unityLibrary:transformNativeLibsWithIntermediateJniLibsForRelease Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:compileReleaseJavaWithJavac Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:bundleLibCompileRelease Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:prepareLintJarForPublish UP-TO-DATE Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:mergeReleaseShaders Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:compileReleaseShaders Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:generateReleaseAssets Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:packageReleaseAssets Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:bundleLibRuntimeRelease Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:processReleaseJavaRes NO-SOURCE Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:bundleLibResRelease Task :unityLibrary:javaPreCompileRelease UP-TO-DATE Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:mergeReleaseJniLibFolders Task :unityLibrary:compileReleaseJavaWithJavac UP-TO-DATE Task :unityLibrary:bundleLibCompileRelease UP-TO-DATE Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:transformNativeLibsWithMergeJniLibsForRelease Task :unityLibrary:bundleLibRuntimeRelease UP-TO-DATE Task :unityLibrary:bundleLibResRelease UP-TO-DATE Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:transformNativeLibsWithStripDebugSymbolForRelease Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:transformNativeLibsWithIntermediateJniLibsForRelease Task :launcher:processReleaseManifest Task :launcher:javaPreCompileRelease Task :launcher:processReleaseResources FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings 51 actionable tasks: 25 executed, 26 up-to-date

UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Console Screenshot

今天遇到了完全相同的问题。您需要升级 gradle 版本。

转到播放器设置 -> 发布设置,然后选中“自定义基础 Gradle 模板”。

Custom Base Gradle Template

在baseProjectTemplate.gradle中,将gradle版本更新为3.4.3

baseProjectTemplate.gradle

这里是 link 到 Unity 的页面,显示了与 Unity 版本兼容的 gradle 版本:https://docs.unity3d.com/Manual/android-gradle-overview.html

这是显示哪个插件具有哪个版本 gradle 的页面:https://developer.android.com/studio/releases/gradle-plugin

基于此你可以升级到3.4.3 这为我解决了问题。

对于可能遇到此问题的任何人: 我升级到 Unity 2020.2.1f1 它为我解决了这个问题, 2020.2.1f1使用的gradle版本兼容中介SDK, 在 2019.4 LTS 版本中没有。 因此,您可以使用 Rini 的解决方案并在旧版本中手动升级 gradle,或者只将 Unity 升级到 2020.2 或更新版本。 两者都应该有效!

已解决。 最新版本的 AdMob SDK(6.) 不适用于 unity 19.4.3,所以我下载了 AdMob SDK(5.4),然后一切看起来都非常好。加油