windows - flutter doctor --android-licenses gives a java error

ID : 10200

viewed : 38

Tags : javawindowsandroid-studioflutterdartjava

Top 5 Answer for windows - flutter doctor --android-licenses gives a java error

vote vote

96

Installing Android SDK Command-line tools from Android SDK Manager did the job for me.

  1. Open Tools > SDK Manager
  2. From the left choose, Appearance & Behavior > System Settings > Android SDK
  3. Select SDK Tools from the top menu
  4. Check Android SDK Command-line tools and click 'apply'.

Alternative to step #1: WINDOWS: File > Settings (Ctrl+Alt+S) / MAC : Android Studio > Preferences

This fix works for Windows, Linux and Mac OS X.


enter image description here

If you are facing a problem in spite of the above steps, you can try upgrading your system to JDK 8. Official documentation of upgrading to JDK 8 is available here.

vote vote

88

I'm a Mac user and I solve this issue.

This answer also helps Windows users and Linux users solve the issue from the user's feedback.

At the first, this is what I met for the issue
$ flutter doctor -v enter image description here

And the following command is not work for my situation.
$ flutter doctor --android-licenses enter image description here

The way to solve this is to install
Android SDK Command-line Tools. And how?
You just need to do it by the following two steps.

Install: Android SDK Command-line Tools

Step 1. Open SDK Manager
Top Menu -> Tools -> SDK Manager enter image description here

Step 2. Install command-line tools

  1. Unfold Appearance & Behavior
  2. Unfold System Settings
  3. Click Android SDK
  4. Click tab of SDK Tools
  5. Check Android SDK Command-line Tools (latest)
  6. Click Apply button. enter image description here Then click OK button to finish installation.

Keep going to sign android licenses.

After Android Studio finishing install, you can do the following.
$ flutter doctor --android-licenses
enter image description here After saying yes many times, all android licenses have been signed.

Check by flutter doctor again.

$ flutter doctor -v
enter image description here

You can see that All Android licenses accepted.

Congratulations, you have completed this task!

vote vote

77

i had the same problem, solved it by installing the coomand-line tools from android studio

click on file, settings then on the search bar type sdk and click in android sdk Android Sdk

Then click on sdk tools, check the android command-line tools box, the click on apply allow to download. then try running flutter doctor --android-licenses again on your cmd you will be prompted to accept licenses

vote vote

70

It seems you are getting a JDK exception, it happens when you does not have JAVA_HOME setted on your system variables OR you have almost setted the JDK but in the wrong folder OR you are trying to run the SDK Manager (which allows you to accept the Android Licenses) with the wrong JDK.

In case of JDK 9 or higher:

Actually, Android SDK Manager works only with Gradle compiled on version of JDK 8 for Android development, so, if you have a most-recent JDK version already setted on system variables, consider to downgrade it to the JDK version 8.

This version works fine for me: https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

In case of JDK 8 already installed

If you manually extracted the JDK folder to a directory, maybe you have setted it "wrong". I mean: You pointed the wrong way to the bin Java folder, but it still works. You have to set JAVA_HOME as the root of JDK, example: In the JDK zipped folder, you have to extract it and point the system variable in the unzipped folder, no directly in the bin directory, you have to point JAVA_HOME as a system variable and declare the bin folder as an executable.

Examples:

Linux

In your shell configuration file:

export JAVA_HOME="/home/user/jdk1.8.0_261" export PATH="$PATH:$JAVA_HOME/bin" 

Windows

In your environment variables manager:

Set a new SYSTEM VARIABLE named JAVA_HOME

enter image description here

Then, edit the PATH variable and add a new register to it:

%JAVA_HOME%\bin 

Actually, I don't know really how to manage JDKs in MacOS, if that is you OS, sorry :(

Hope it helps!

vote vote

59

You need JDK 8 since the required files were removed in later versions.

Once installed you can switch between versions using

sudo update-alternatives --config java 

then select the option for JDK 8. This will also show you the location of your JDK 8 installation which you'll need for:

export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/" PATH=$PATH:$JAVA_HOME/bin 

Top 3 video Explaining windows - flutter doctor --android-licenses gives a java error

Related QUESTION?