2
votes

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
Fixed tags as the problem have nothing to do with android but rather android-studio and java version - Yash Joshi
Android Studio has a separate configuration for the Java version used to run gradle. If it is a legacy project you just want to compile you can do so without Android Studio. Just execute gradle from command-line. There you have full control on the used JRE. - Robert

1 Answers

0
votes

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!