当我尝试使用 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()

最佳答案

将 JAVA_HOME 添加到我的环境变量中,它是 C:\Program Files\Java\jdk1.8.0_144 它对我有用,也许对你有用。

关于unity3d - Gradle 无法获取依赖项 |解析失败 - 在 Unity3d,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46681503/

10-12 05:10