The “Gradle sync failed” error
Coding apps in Android can be a lot of fun. But it can also be immensely frustrating. I recently updated my JDK, after Android Studio gave me a warning about using an outdated JDK. Then I got an error “Gradle sync failed: Please use JDK 8 or newer” as shown below.
Gradle sync failed 1

I spent half a day, trying to solve this problem, but I finally nailed it.

The solution
Every app has a variable stored in the file, that points to the Java compiler environment to use. Maybe it’s just my old computer or there is a problem with Android Studio, but there is a problem recognizing the new path. I tried browsing to the new path, in the file explorer dialog box, but it kept going back to the old, non-existent path. INT

Gradle sync failed 2

You first need to make sure that the new JDK installed properly. All Android needs is the JDK, not the JRE. The JDK package already contains a JRE in it, so there’s no need to download and separately install the JRE package. If you’re sure that the JDK is properly installed, run a java version command as shown below.

It can be run from any directory, not in the jdk as shown in the picture above. If you’re running a Windows system, like I am, ensure that your path has no spaces in it. Some people suggest that you copy your SDK to a path that has no spaces in it. But this isn’t necessary. Instead you can pass old style DOS paths to the Android Studio dialog. A good reference about how to do this can be found here.

After pasting in the new path, you may have to restart Android Studio and confirm that it has “accepted” the new path. This works most of the time.

Categories: Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *

Visit Us On TwitterVisit Us On Facebook