Android Gradle plugin requires Java 11 to run. Changing it to 11 or above has no effect

Viewed 251

This question is fairly old on Stackoverflow but none of the provided solutions worked for me. So I try to generate an Android App Bundle with Android Studio and first receive the message

Generate Signed Bundle: Errors while building Bundle file. You can find the errors in the 'Messages' view.

which results in

Cause: argument type mismatch

Then in the terminal I run

./gradlew build --warning-mode all

which gives me:

enter image description here

So I tried various things:

  1. Android Studio (Arctic Fox) => Preferences => Build/Execution/Deployment => Buidl Tools => Gradle => set Version to 11.0.10

enter image description here

I also tried Version 17. No success. Still the same error on building

  1. I reset Android Studio to default settings. After restart there was a popup asking me to change SDK from 1.8 - I clicked there and did the change. No success. Still the same error.

  2. I run ./gradlew --version in Terminal and receive this

enter image description here

So basically everything I do regarding changing the SDK has no effect. Honestly I am out of options now and don't know what to do next.

2 Answers

As I can see, your gradle project still uses JDK 1.8. There can be two solutions:-

  1. Add this to your gradle.properties file: org.gradle.java.home=path/to/jdk/11+

  2. Ensure that your gradle.properties file doesn't have a java home declaration and then, append the path of JDK 11 bin folder to your PATH environment variable.

On MAC, this worked for me

export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home
Related