当我尝试使用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()
答案 0 :(得分:3)
将JAVA_HOME添加到您的环境变量中它是 C:\ Program Files \ Java \ jdk1.8.0_144 它对我有用,也许它适合您。
答案 1 :(得分:1)
对我来说,最新的Google Play服务解析器无法将库play-services-ads.aar
复制到/Assets/Plugins/Android
。我必须从sdk文件夹手动复制它:
sdk\extras\google\m2repository\com\google\android\gms\play-services-ads
到我的
/Assets/Plugins/Android
文件夹。
答案 2 :(得分:0)
从 Asset Name 文件夹中删除所有 Google AdS 文件并重新导入 Google AdS 包。
或
-右键单击“我的电脑”并转到属性。
-转到高级选项卡
-点击环境变量按钮
-在系统变量下找到JAVA_HOME变量
-将值更改为该文件实际存在的位置。 (对我来说是 C:\Program Files\Java\jdk-10)
-重启Unity
答案 3 :(得分:0)
我必须添加unity->Edit->preferences中给出的Jdk地址
并将地址粘贴到 JAVA_HOME 变量值中。
然后我重新启动系统,它获取了所有 android 依赖项并开始工作。
如果它没有自己开始获取,你可以强制解析android依赖项。Assets->ExternalDependencyManager->AndroidResolver->force Resolve。