>[!] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    >>• Android SDK a ..\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-27, build-tools 27.0.3
    • Java binary at C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
    X Android license status unknown.

Я получаю сообщение об ошибке с Android SDK при запуске Flutter doctor, хотя я все еще могу собрать / запустить его на своем устройстве. Мне просто было любопытно, как исправить эту проблему. Я считаю, что у меня загружена самая последняя версия Android SDK, но не знаю, что случилось, потому что на прошлой неделе у меня не было этой проблемы.

## Новые выпуски После нескольких возможных исправлений в комментариях это привело к новой проблеме. Я установил более новые версии android sdk P, 8 и 7 вместе с новым jdk10. По-видимому, все еще недостаточно обновлен.

C:\Flutter\flutter>flutter doctor --android-licenses
A newer version of the Android SDK is required. To update, run:
C:\Users\tdmil\AppData\Local\Android\sdk\tools\bin\sdkmanager --update

C: \ Flutter \ flutter> C: \ users \ username \ appdata \ local \ android \ sdk \ tools \ bin \ sdkmanager.bat --update

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
        at com.android.repository.api.SchemaModule$SchemaModuleVersion.(SchemaModule.java:156)
        at com.android.repository.api.SchemaModule.(SchemaModule.java:75)
        at com.android.sdklib.repository.AndroidSdkHandler.(AndroidSdkHandler.java:81)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
        ... 5 more

Ответы (31)

Если вы обновили Android SDK, возможно, изменились лицензии. В зависимости от того, как вы выполнили обновление, вам может быть предложено принять изменения, а может и нет, или, может быть, это просто не сохраняет тот факт, что вы их приняли так, как это может понять flutter.

To resolve, try running

flutter doctor --android-licenses

This should prompt you to accept licenses (it may ask you first, in case just type y and press enter - although it should tell you that).

If you still have problems after doing that, it might be worth either opening a new bug in the Flutter Github repository, or adding a comment on an existing issue like this one as it may be what you're seeing.

  1. Откройте Android Studio.
  2. Перейдите в Файл-> Настройки.
  3. Искать AndroidSDK.
  4. Обновите свой уровень API до последней версии.
  5. Затем перезагрузите Android Studio.

откройте файл flutter_console.bat из корневой папки flutter SDK и выполните команду

flutter doctor --android-licenses

it will accept the licenses of newly downloaded updates of Android SDK. You need to run it every time whenever you download and update the Android SDK.

Ошибка:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
        at com.android.repository.api.SchemaModule$SchemaModuleVersion.(SchemaModule.java:156)
        at com.android.repository.api.SchemaModule.(SchemaModule.java:75)
        at com.android.sdklib.repository.AndroidSdkHandler.(AndroidSdkHandler.java:81)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
        ... 5 more

is occurring because the current SDK version is incompatible with Java 9.

So, to solve it, you can downgrade your java version to Java 8, or with a workaround, you can export the following option on your terminal:

Linux:

export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'

Windows:

set JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'

And to make it stick, you can export the JAVA_OPTS in your profile file on Linux (.zshrc, .bashrc and etc.) or add as an environment permanently on Windows.


Then, you can type the flutter or sdkmanager command:

Flutter:

flutter doctor --android-licenses

sdkmanager:

sdkmanager --licenses

and type Y when needed to accept the licenses.

ps. This doesn't work for Java 11/11+, which doesn't have Java EE modules. For this option is a good idea, downgrade your Java version or wait for a Flutter update.

Ref: JDK 11: End of the road for Java EE modules

Я нашел это решение. Я загружаю JDK 8, затем добавляю имя пути к файлу JAVA_HOME для загрузки jdk в пользовательские переменные в переменной среды.

Я понизил свою версию Java до 1.8, и проблема решена, вот ссылка для загрузки JDK8

Run the following command after installing JDK8

   flutter doctor --android-licenses

Я столкнулся с той же проблемой, как уже упоминалось выше, я пробовал это.

  1. Installed JDK 1.8 and set my JAVA_HOME env to 1.8 - This did not work
  2. My Android studio didn't show any "Android SDK Tools (Obsolete)" but had had an "Android SDK Tools"

This is what worked for me:

  1. Delete the "Android SDK Tools" from SDK Manager
  2. Reinstall it by first deselecting the "Hide Obsolete Packages" and then select "Android SDK Tools (Obsolete)", install it.
  3. run flutter doctor --android-licenses and select y for the prompts
  4. run flutter doctor and everything will be fine!!!!

Я пишу это из-за разочарования при установке flutter ... Большинство проблем вызвано простыми проблемами конфигурации. Выполните следующие действия, чтобы решить свои проблемы.

STEP 1:ANDROID LICENSES --android-licenses, will resolve most cases

Since you are here you have reached "Android License Status Unknown" issue for Android tool chain,as many suggested tryflutter doctor --android-licenses. If you are good with all the config. It should ask for an yes and press y and Voila. But if it shows a

enter image description hereAndroid sdkmanager tool not found (C\Users\__\local\Android\sdk\tools\bin\sdkmanager). Go to step two

STEP 2: SDK Manager installation from Android Studio

Open your Android Studio , File-> settings->System settings(left tab) ->Android SDK, go to SDK Tool section in that page, untick hide obsolete packages, select Android SDL tools(obsolete) and press apply.

enter image description here It will install the SDK and you confirm it by going and checking if this path exists(C\Users\__\local\Android\sdk\tools\bin\sdkmanager)

STEP 3: Repeat 1

Repeat step 1 after installation in a new command line check if its working , else go to STEP 4

STEP 4: sdkmanager --update

It will ask you update the sdk, just run the command given in terminal C\Users\__\local\Android\sdk\tools\bin\sdkmanager --update. If it is running, then its cool. let it finish and repeat step 1, else if it is throwing some exceptions like java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema etc, java_error it means your java is not installed or not the correct version. Go to next step

STEP 5: JAVA 8.1 and JAVA_HOME path.

Install JAVA 8.1 and set JAVA_HOME path. Make sure it is version 8.1(register free account and download from oracle the 8.1 version, remember above 11+ wont work for flutter enter image description here

NOTE: by yaniv maymon: if you already have Java installed on your computer and the sdkmanager --update still not working. go the environment variable and update the "JAVA_HOME" path to jdk folder. then exit the command prompt, open it again and run the update command –

STEP 6: Final Step

After installing and setting up path properly, run theC\Users\__\local\Android\sdk\tools\bin\sdkmanager --update command in new terminal and it will work

STEP 7: Rerun flutter doctor, You can see it saying to run the command flutter doctor --android-licenses . so run flutter doctor --android-licenses in terminal and press y when asked

Для Windows людей краткосрочным решением является переход на JDK8. Надеюсь, flutter скоро решит проблему для Android SDK, который будет работать с> JDK8.

Моя среда: Windows 10 64bit, OpenJDK 14.0.2

Initial errors are as reported above.

Error was resolved after

  1. Replaced "C:\openjdk-14.0.2_windows-x64_bin\jdk-14.0.2" with "*C:\Program Files\Android\Android Studio\jre*" in environment variable PATH & JAVA_HOME
  2. ran flutter doctor --android-licenses and selected y for the prompts

После большого анализа моей Ubuntu 20.04 я нашел решение

for me the error was /home/rk/Android/Sdk/tools/bin/sdkmanager was missing write permission.

  1. chmod +w home/rk/Android/Sdk/tools/bin/sdkmanager

Then run the below command.

  1. flutter doctor --android-licenses

it automatically process the licences.

Для тех из вас, кто работает в Linux и продолжает получать ошибки во время flutter doctor --android-licenses.

I kept getting the could not create settings warning when trying to accept licenses, which I fixed by specifying SDK location:

sdkmanager --sdk_root=/home/adel/bin/android-sdk --licenses

Sdkmanager then printed: all SDK package licenses accepted.

However Flutter kept giving the android license status unknown error. And attempting to call flutter doctor --android-licenses would give me the same could not create settings error I used to get.

To fix this I edited the sdkmanager script located in ${your android tools location}/tools/bin/ and changed the last line from:

exec "$JAVACMD" "$@"

To:

exec "$JAVACMD" "$@" --sdk_root=/home/adel/bin/android-sdk

This would make Flutter call sdkmanager while passing the needed sdk_root argument, a final call to flutter doctor --android-licenses fixed the issue.

I did not have to use Java 8.

В моем случае проблема отсутствовала Инструменты командной строки Android SDK

enter image description here

Просто установите инструмент командной строки sdk (последний), указанный ниже, в студии Android. enter image description here

Then run: flutter doctor --android-licenses

After which you should get:

coolcoders@myhost ~ % flutter doctor --android-licenses
5 of 7 SDK package licenses not accepted. 100% Computing updates...             
Review licenses that have not been accepted (y/N)? y

...and then you'll get a whole bunch of licenses to read whilst you sip your favourite beverage.

Попробуйте понизить версию Java, это произойдет, если версия Java вашей системы несовместима с версией из Android. После смены версии java просто запустите flutter doctor, она автоматически примет лицензии.

Эта строка, представленная в сообществе GitHub, решила мою проблему, здесь она на всякий случай поможет кому-то еще.

@rem Execute sdkmanager

"%JAVA_EXE%" %DEFAULT_JVM_OPTS% -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee %JAVA_OPTS% %SDKMANAGER_OPTS% -classpath "%CLASSPATH%" com.android.sdklib.tool.sdkmanager.SdkManagerCli %CMD_LINE_ARGS%

Если вы используете бочонок для домашнего пивоварения, вы можете сделать

brew cask install android-sdk
mkdir ~/Library/Android/sdk/tools
ln -s /usr/local/bin/ ~/Library/Android/sdk/tools/bin
flutter doctor --android-licenses

Для тех, кто все еще сталкивается с проблемой:
Как ответил ниже Tommie C, Aba и несколько других людей, но может быть недостаточно ясно, как я нашел.
Попробуйте установить java 1.8 вручную, как описано здесь для windows / linux: [https://www3.ntu.edu.sg/home/ehchua/programming/howto/JDK_Howto.html]
и установка $ JAVA_HOME переменной (путь jdk).
В Windows установите путь jdk ($ JAVA_HOME): [Как установить java_home в Windows 7?.
В Linux: [https://askubuntu.com/questions/175514/how-to-set-java-home-for-java].
Затем запустите flutter doctor --android-licenses и примите все лицензии. Надеюсь, это поможет.

Выполните следующие простые шаги.

  1. go to tools, then SDK manager, then click on android SDK.
  2. click SDK update sites tab.
  3. check the checkbox that states https://..sources to be fetched using https://.
  4. click apply and ok.
  5. Now restart android studio.
  6. go to SDK tools and check the checkbox that states Hide obsolete packages.
  7. wait for about a minute or so for the packages appear.
  8. then select a package called "android SDK tools (obsolete), and press okay.
  9. continue to install the package.
  10. after installation restart android studio and also restart cmd, then run flutter doctor.
  11. it will take a couple of minutes and it should work

Вот что я сделал, чтобы исправить свою проблему. Обратите внимание, что вам не нужно удалять старую копию Android Studio / SDK. Android Studio позаботится об этом, пока вы устанавливаете последнюю версию.

  1. Downloaded & install the latest version of Android Studio
  2. Follow the instructions in this tutorial
  3. Once the installation is complete, run flutter doctor and check, your issue should have been resolved. If the issue is resolved, there's no need to run the flutter doctor --android-licenses command.

Вот шаги, которые решают мою проблему:

  1. Open your terminal
  2. type flutter doctor --android-licenses
  3. press y to accept, this process may occurred several times. Done!

вот мое решение:

  1. install SDKMan

    $ curl -s "https://get.sdkman.io" | bash

  2. setting your bash_profile

    $ source "$HOME/.sdkman/bin/sdkman-init.sh

    $ source ~/.bash_profile

  3. find java sdk, and select want to install version

    $ sdk ls java

    $ sdk install java 8.0.192-zulu

  4. copy your flutter doctor warning message to update sdkmanager

    $ /Users/YourUserName/Library/Android/sdk/tools/bin/sdkmanager --update

  5. after 1~4, redo it

    $ flutter doctor --android-licenses

Я столкнулся с проблемой. Папка tools также отсутствовала в папке Android SDK. Я считаю, что папка tools появляется только после установки Android SDL tools (устаревшие). Эта опция была недоступна для меня.

Solution: I upgraded the Java from version 8 to version 12 and I was able to install the tools. You may still get the error Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses while giving the command flutter doctor -v. Run the command flutter doctor --android-licenses, the licences will be reviewed when you click yes every time this question appears Accept? (y/N):

Hopefully it will help someone.

Еще в 2021 году я столкнулся с такой же проблемой с

  • Android Studio - Arctic fox 2020.3.1 Patch 2
  • Java jdk-16.0.2
  • Android SDK Version 31.0.0
  • Flutter 2.5

I have tried the answers above except for editing the sdkmanager.bat file. But NO SUCCESS at all.

Then I upgraded flutter 2.5 to 2.5.1 using the "flutter upgrade" command. Now it is working. NO issues with the "flutter doctor" command.

Я нашел это решение для использования JDK 8 (вам нужна учетная запись для загрузки сейчас!) - используйте встроенный OpenJDK, который поставляется с Android Studio:

Add this to your ~/.profile or similar:

# Use the JDK embedded with Android Studio for command-line builds
export JAVA_HOME='/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home'

Command-line builds via gradlew, and any other well-behaved script, will then use the version of the SDK that ships with Android Studio 2.2+.

*My Mac was still using the default Java 7.

ПРЕДУПРЕЖДЕНИЕ: Этот ответ полезен, если у вас есть проблемы с переменной окружения JAVA_HOME и ее направлением. Если у вас нет этой проблемы, вам не следует пробовать это решение.

If you have this error and you tried with flutter doctor --android-licenses or sdkmanager --licenses and you got a problem with your JAVA_HOME environmental variable, then you have to read this.

I have a MacOS Catalina ant I could resolve this problem successfully with the next steps:

  1. Open your terminal
  2. Type: open -e .bash_profile (You should see almost two environmental variables: flutter and JAVA_HOME)
  3. Save JAVA_HOME environmental variable written there in a textEdit file if you wish and DELETE the JAVA_HOME environmental variable. Save the bash_profile.
  4. Go to terminal again and run source $HOME/.bash_profile
  5. Try again flutter doctor and you shouldn't see the same error any more.

Please, let me know if you have doubts.

Правильным решением будет, если у вас установлена ​​студия Android, а затем

  1. open SDK manager
  2. under SDK tools uncheck hide obsolete packages at the bottom
  3. then you should see an option called Android SDK Tools (Obsolete)

enter image description here

  1. check it and apply and let the studio download the package
  2. once done run the command flutter doctor and it should now prompt you to run flutter doctor --android-licenses once you run the license command accept all licenses by hitting y and it should solve the problem

enter image description here

Обратитесь -https://robbinespu.gitlab.io/blog/2020/03/03/flutter-issue-fixed-android-license-status-unknown-on-windows/

So here the solution, open your SDK manager then uncheck Hide Obsolete Packages

enter image description here

Now you’ll see Android SDK Tools (Obsolete) 26.1.1 appears. Tick that package and hit apply button then ok button. it will download sdk. then restart Android studio

Nice, now if you run flutter doctor, you should get positive result as below

PS D:\Workplace\flutter_projects> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Version 10.0.18363.657], locale en-MY)

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[√] Android Studio (version 3.6)
[√] VS Code (version 1.42.1)
[√] Connected device (1 available)

• No issues found!

PS D:\Workplace\flutter_projects> flutter doctor --android-licenses -v
All SDK package licenses accepted.======] 100% Computing updates...

Run flutter doctor --android-licenses and enter Y when is asked

if needed we can download package manually here https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip (for Windows user). Hope this tutorial help people who looking for solution

MacOS 10.15: Android Studio 3.5.1:

The solution that works for me was to use the Java Environment tool jenv (installed via homebrew). This tool changes the $JAVA_HOME when one switches between java versions.

In my case I have multiple Java versions installed and the current global version in use was the default. I also found it necessary to comment out the $JAVA_HOME environment variable in my .bash_profile when using this tool.

In Terminal, I entered jenv global 1.8 to get java 1.8 running instead of a later version (I have multiple versions installed).

After that:

flutter doctor --android-licenses

OR

sdkmanager --licenses

both work fine.

Note: You may need to exit and reopen your Terminal shell if you have to redefine the $JAVA_HOME environment variable.

У меня такая же проблема, проверьте свою версию java минимум 1,8

Это тоже была моя проблема, такая же, как # 16025

For an Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema This issue seems usually happens when you've installed Java 9 before. BTW it's not compatible with android-sdk try to remove Java 9 JDK if still exist.

In general JAXB APIs are considered to be Java EE APIs, and therefore are no longer contained on the default class path in Java SE 9. Java 9 introduces the concepts of modules, and by default the java.se aggregate module is available on the class path (or rather, module path). As the name implies, the java.se aggregate module does not include the Java EE APIs that have been traditionally bundled with Java 6/7/8. Fortunately, these Java EE APIs that were provided in JDK 6/7/8 are still in the JDK, but they just aren't on the class path by default. The extra Java EE APIs are provided in the following modules

Solution to workaround if you have Java9/10 installed

  1. Open sdkmanager in your editor.
  2. Append DEFAULT_JVM_OPTS

Replace

DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME"'

With this one

DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
  1. Save the file and quit the editor then try run the command again.

For Android license status unknown issue, I've tried to solve by these steps:

  1. Open a terminal
  2. Go to your Android SDK location C:\Users%user%\AppData\Local\Android\Sdk\tools\bin or ~/Library/Android/sdk/tools/bin

  3. Run the command: ./sdkmanager --license

References

Failed to run sdkmanager --list (Android SDK) with Java 9

How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9

2022 WebDevInsider