Getting error Gradle failed to fetch dependencies for Google admob plugin

I am getting this error when integrating Google Admob Plugin when try to force resolve from Android Resolver.

Unity version: 2017.2.0f3 personal.
GoogleMobileAds v3.10.0.unitypackage
JDK: jdk1.8.0_144

Any help will be appreciated.

Gradle failed to fetch dependencies.

Failed to run 'D:\Temp\PlayServicesResolverGradle\gradlew.bat -b "D:\Temp\PlayServicesResolverGradle\PlayServicesResolver.scripts.download_artifacts.gradle" --no-daemon "-PANDROID_HOME=sdk-2" "-PTARGET_DIR=Game\Assets\Plugins\Android" "-PMAVEN_REPOS=https://maven.google.com" "-PPACKAGES_TO_COPY=com.google.android.gms:play-services-ads:11.6.0"'
stdout:

ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_144;

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)
Google.Logger:Log(String, LogLevel)
GooglePlayServices.PlayServicesResolver:Log(String, LogLevel)
GooglePlayServices.<GradleResolution>c__AnonStorey14:<>m__1F(Result)
GooglePlayServices.<GradleResolution>c__AnonStorey15:<>m__28()
GooglePlayServices.PlayServicesResolver:PumpUpdateQueue()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

Thanks

Hi @pawnakumar113,
_
The issue is this:
JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_144;
_
The solution (at least for windows users) is:

  1. Right click on “my computer” and go to properties.
  2. Go to the Advanced tab
  3. Click on the Environmental Variables… button
  4. Find the JAVA_HOME variable under System Variables
  5. Change the value to wherever this file actually exists for you. (for me it was C:\Program Files\Java\jdk-10)
  6. Restart Unity

I hope that helps!

Anyone who struggles with this problem, it is caused by a unity bug!
I have a solution which works great for me:

Fix Steps:

1- Go to “Edit → Preferences → External Tools”

2- Uncheck and re-check “JDK” under android section and you’re done!..

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

My computer is macbook. Can you help me too?

bilgisayar mac bu sorunu çözmek için nasıl bir yöntem deneyebiliriz?

Resolution Failed Unity, Force Resolve [Solved] Android Resolver Unity, Failed to Fetch Dependencies - YouTube this works on me, (Gradle update ederseniz bu şekilde sorununuz çözülecektir.)