0

Whenever I open my Flutter project's android module in Android Studio, it gives me the following error:

Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.

To solve it, I open Gradle settings and change Gradle JDK from 1.8 to 11, hit Apply button and it works.

enter image description here

However, if I reopen the same project (after closing), it resets my JDK to 1.8. I need to set it to 11 again. What am I doing wrong?

PS: My other Android projects (native ones using Java) does remember the last selected JDK version.

iDecode
  • 22,623
  • 19
  • 99
  • 186
  • Have you ever used IntelliJ IDEA with this project? – Andrey Nov 30 '21 at 16:14
  • Try this: https://stackoverflow.com/a/21212790/2000323 – Andrey Nov 30 '21 at 16:14
  • @Andrey No, I didn't use IntelliJ IDEA for this project. Thanks for the link, I knew how to do that in gradle file but I'm curious to know why my Flutter project is having this issue. – iDecode Dec 01 '21 at 07:52

1 Answers1

0

2023 Update

I was trying to update from VERSION 1.8 to VERSION 11. Went through the solutions on the web and found none working. I couldn't find the file at the specified location. The file has been changed in the newer releases.

Step 1: Open the Android Studio and keep it open.

Step 2: Go to the location given below:

C:\Users\{username}\AppData\Roaming\Google\AndroidStudio2022.1\options

or press Win + R and enter the following:

%userprofile%\AppData\Roaming\Google\AndroidStudio2022.1\options

Your latest version of Android Studio might be different.

Step 3: Delete the file jdk.table.xml from the options folder.

Step 4: Change the Gradle JDK to the new JDK in the settings, so that the Studio can save the new path in the file. (Important: Else Studio assigns JDK from it's memory)

Step 5: Restart Android Studio.

This fixed the issue for me. The newly created jdk.table.xml will have the updated JDK values.

iDecode
  • 22,623
  • 19
  • 99
  • 186