Arif Khan
Arif Khan

Reputation: 97

Gradle failed to fetch dependencies | Resolution failed -in Unity3d

This error occurs when I try to build&Run my game with Unity. I've also imported the GooglePlayServices/ads from here and also have the latest android sdk and jdk-8u144.

Here is the Error Log:

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

2nd Error:

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

Upvotes: 4

Views: 19424

Answers (5)

Haluk &#214;zgen
Haluk &#214;zgen

Reputation: 31

i tried with jre 1.8 typing JAVA_HOME, it resulted in success.

Upvotes: 0

Suvamjyoti Panda
Suvamjyoti Panda

Reputation: 1

I had to add the Jdk address as given in unity->Edit->preferences

and paste the address in the JAVA_HOME variable value.

then I restart my system and it fetched all the android dependencies and started working.

if it does not start fetching on its own you can force resolve the android dependencies.Assets->ExternalDependencyManager->AndroidResolver->force Resolve.

Upvotes: 0

Bhautik Jikadra
Bhautik Jikadra

Reputation: 11

Delete all Google AdS files from the Asset Name folder and re-import the Google AdS package.

Or

-Right click on "my computer" and go to properties.

-Go to the Advanced tab

-Click on the Environmental Variables button

-Find the JAVA_HOME variable under System Variables

-Change the value to wherever this file actually exists for you. (for me it was C:\Program Files\Java\jdk-10)

-Restart Unity

Upvotes: 1

Boogie
Boogie

Reputation: 360

add JAVA_HOME to your environment variables for mine it is C:\Program Files\Java\jdk1.8.0_144 It worked for me maybe it will for you.

Upvotes: 3

Marek Glapa
Marek Glapa

Reputation: 11

For me latest Google Play Services resolver cannot copy library play-services-ads.aar to /Assets/Plugins/Android. I have to copy it manually from sdk folder:

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

to my /Assets/Plugins/Android folder.

Upvotes: 1

Related Questions