Android Studio - Could not determine Java version using executable

Viewed 1655

I'm using macOS 11.3 and I currently have an Android project with the Android Gradle plugin version 3.2.1 and Gradle version 3.4 that I'm trying to compile with Android Studio 4.2.1. As this version of Android Studio comes with JDK 11 as a runtime, I've tried to change the runtime of the IDE as detailed here and here

but I'm getting the following error:

Could not determine Java version using executable /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java.

The project uses Gradle 3.4 which is incompatible with Java 10 or newer. See details at https://github.com/gradle/gradle/issues/4503 Possible solution:

  • Upgrade Gradle wrapper to 4.8.1 version and re-import the project

Upgrading the Gradle version is not an option in my case due to it's a legacy project that is no longer maintained and in the end, I would have some other compilation problems.

What I've tried to do is change the JDK of Android Studio to use JDK 8 as detailed but I'm getting the error "Could not determine Java version using executable /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java."

Does anybody has had the same problem? Can it be related to the path set on the Java_HOME variable?

1 Answers

This seems to be similar to this.

You can uninstall all existing JDK versions including 11 and install Java 8. Then try again after setting version 8 in your Studio as well as in the environment variable (JAVA_HOME path).

Hope that works for you!

Related