JAVA_HOME is set to an invalid directory - Android Studio

58 Views Asked by At

Steps to reproduce

  • Error.
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/openjdk-11

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

I went to this directory and found

enter image description here

  • I have changed the default JAVA_HOME path to enter image description here

enter image description here

  • after changing the defalut java home path, i still get this error.
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/openjdk-11

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

Code sample

ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/openjdk-11

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

Expected results

The Default JAVA-HOME path should change in android studio too, since i have changed it on my computer. at least that what i think should happen.

Actual results

I get the same error which contain the previous directory

1

There are 1 best solutions below

0
Mohamed Ali On

The Problem is solved by Upgrading the Flutter SDK

flutter upgrade