Gradle 无法获取依赖项 |解析失败-in Unity3d

问题描述 投票:0回答:5

当我尝试使用 Unity 构建和运行我的游戏时出现此错误。我还从 here 导入了 GooglePlayServices/ads,还有最新的 android sdk 和 jdk-8u144。

这是错误日志:

Gradle failed to fetch dependencies


Failed to run 'Temp\PlayServicesResolverGradle\gradlew.bat -b Temp\PlayServicesResolverGradle\PlayServicesResolver.scripts.download_artifacts.    gradle --no-daemon "-PANDROID_HOME=C:/Users/rfkha/AppData/Local/Android/sdk1" "-    PTARGET_DIR=C:\Users\rfkha\Documents\Space Shooter\Assets\Plugins\Android" "-    PMAVEN_REPOS=https://maven.google.com" "-    PPACKAGES_TO_COPY=com.google.android.gms:play-services-ads:11.2.2"'
stdout:

ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

stderr:

exit code: 1

UnityEngine.Debug:LogError(Object)
GooglePlayServices.PlayServicesResolver:LogDelegate(String, LogLevel)
Google.JarResolver.PlayServicesSupport:Log(String, LogLevel, Boolean)
GooglePlayServices.<GradleResolution>c__AnonStorey14:<>m__20(Result)
GooglePlayServices.<GradleResolution>c__AnonStorey15:<>m__29()
GooglePlayServices.PlayServicesResolver:PumpUpdateQueue()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

第二个错误:

Resolution failed

Failed to fetch the following dependencies:
com.google.android.gms:play-services-ads:11.2.2


UnityEngine.Debug:LogError(Object)
GooglePlayServices.PlayServicesResolver:LogDelegate(String, LogLevel)
Google.JarResolver.PlayServicesSupport:Log(String, LogLevel, Boolean)
GooglePlayServices.ResolverVer1_1:LogMissingDependenciesError(List`1)
GooglePlayServices.<DoResolutionUnsafe>c__AnonStorey17:<>m__26(List`1)
GooglePlayServices.<GradleResolution>c__AnonStorey14:<>m__20(Result)
GooglePlayServices.<GradleResolution>c__AnonStorey15:<>m__29()
GooglePlayServices.PlayServicesResolver:PumpUpdateQueue()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
unity-game-engine google-play-services googleads-mobile-unity
5个回答
3
投票

将 JAVA_HOME 添加到我的环境变量中它是 C:\


1
投票
play-services-ads.aar

复制到

/Assets/Plugins/Android
。我必须从 sdk 文件夹中手动复制它:

sdk\extras\google\m2repository\com\google\android\gms\play-services-ads

我的
/Assets/Plugins/Android

文件夹。

    


1
投票

-右键单击“我的电脑”并转到属性。

-转到“高级”选项卡

-点击环境变量按钮

-在系统变量下找到JAVA_HOME变量

-将值更改为该文件实际存在的位置。 (对我来说是 C:\Program Files\Java\jdk-10)

-重启Unity


0
投票

并将地址粘贴到 JAVA_HOME 变量值中。

然后我重新启动我的系统,它获取了所有的 android 依赖项并开始工作。

如果它没有开始自行获取,您可以强制解析 android dependencies.Assets->ExternalDependencyManager->AndroidResolver->force Resolve.


0
投票

© www.soinside.com 2019 - 2024. All rights reserved.