2017-10-11 298 views
1

當我嘗試構建&時發生此錯誤使用Unity運行我的遊戲。我還從here導入了GooglePlayServices/ads,並且還有最新的android sdk和jdk-8u144。Gradle無法獲取依賴關係|解析失敗 - 在Unity3d

下面是錯誤日誌:

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() 

回答

1

對我來說,谷歌最新的播放服務解析器無法複製庫play-services-ads.aar/Assets/Plugins/Android。我必須從SDK文件夾手動複製:

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

/Assets/Plugins/Android文件夾。

+0

酷男,你的解決方案幫了我很多:) – tamtoum1987

0

將JAVA_HOME添加到您的環境變量中,它對我來說是C:\ Program Files \ Java \ jdk1.8.0_144它對我來說也許會對您有用。

相關問題