The gradle version in the app I am trying to import is not compatible with JDK11, which is what android studio uses as its embedded JDK. I have JDK8 on my machine. I have tried going into project structure to change the path to the JDK8 location, but I get an error if I try to change it. It says I must choose a valid JDK 11 directory. How can I get android studio to use JDK 8? error screenshot
How can I get android studio to use JDK 8?
Android Studio 4.2 onwards runs on Java 11. It is stated clearly in the documentation.
I have not found any description of workarounds to make Android Studio 4.2 work on Java 8, and I doubt that is technically possible. For a start, the Android Studio 4.2 distro will contain classes compiled for Java 11, and a Java 8 JDK won't be able to load them due to classfile version mismatches. So you would need to rebuild Android Studio from source code. And to do that you would have the problem of backporting various Java-11-isms in the AS 4.2 codebase to work on Java 8.
In short, it is not practical.
You will need to upgrade the old Gradle version / plugins that your app depends on. Alternatively, use an older version of Android Studio that will run on Java 8 ... until you can upgrade Gradle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With