Nas
Nas

Reputation: 1

Flutter: JAVA_HOME is set to invailed directorty

I installed flutter on Ubuntu 20.4 and checked flutter doctor(no issues) I opened the test project and tried to run it and I get this error:

Running Gradle task 'assembleDebug'...

ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-15-oracle

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

Exception: Gradle task assembleDebug failed with exit code 1

here is the echo $JAVA_HOME

/usr/lib/jvm/java-8-openjdk-amd64

it is the right one, I've uninstalled oracle-jdk from my device but still getting this error

Upvotes: 0

Views: 223

Answers (1)

Saiful Islam
Saiful Islam

Reputation: 1269

You have to set your JAVA_HOME path to jre directory

in my case that is something like this

C:\Program Files\Android\Android Studio\jre

Now go to your Environment variable and set your JAVA_HOME path to your jre directory

Image

Upvotes: 1

Related Questions