简体   繁体   English

Flutter.io Android 许可证状态未知

[英]Flutter.io Android License Status Unknown

>[!] 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.

I am getting an error with Android SDK when I run Flutter doctor, although I can still build/run it on my device.我在运行 Flutter 医生时收到 Android SDK 错误,尽管我仍然可以在我的设备上构建/运行它。 I was just curious about how to fix this issue.我只是好奇如何解决这个问题。 I believe I have the most updated version of the Android SDK downloaded, not sure what happened because I didn't have this issue last week.我相信我已经下载了 Android SDK 的最新版本,不确定发生了什么,因为我上周没有遇到这个问题。

##New Issues After following several possible fixes in the comments it has led to a new problem. ##New Issues 在评论中进行了几个可能的修复后,它导致了一个新问题。 I installed newer versions of android sdk P, 8, and 7 along with a new jdk10.我安装了更新版本的 android sdk P、8 和 7 以及新的 jdk10。 Still not updated enough apparently.显然还不够更新。

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 C:\Flutter\flutter>C:\users\用户名\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.<init>(SchemaModule.java:156)
        at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
        at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(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

Just install the sdk command line tool(latest) the below in android studio.只需在android studio中安装sdk命令行工具(最新)即可。 在此处输入图片说明

Then run: flutter doctor --android-licenses然后运行: 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. ...然后您将获得一大堆许可证,可在您啜饮您最喜爱的饮料时阅读。

If you updated the android SDK, the licenses may have changed.如果您更新了 android SDK,则许可可能已更改。 Depending on how you did the update you may or may not have been prompted to accept the changes, or maybe it just doesn't save the fact that you did accept them in a way flutter can understand.根据您进行更新的方式,您可能会或可能不会被提示接受更改,或者它可能只是没有保存您确实以一种颤振可以理解的方式接受它们的事实。

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).这应该会提示您接受许可证(它可能会先询问您,以防只需键入y并按 Enter - 尽管它应该会告诉您)。

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.如果您仍然有这样做之后的问题,它可能是值得要么开在一个新的bug扑Github上库,或像现有的问题添加注释这一个,因为它可能是你看到的。

The error:错误:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
        at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
        at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
        at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(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.发生的原因是当前的 SDK 版本与 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:因此,要解决此问题,您可以将 Java 版本降级到 Java 8,或者使用一种变通方法,您可以在终端上导出以下选项:

Linux: 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.为了让它坚持下去,您可以在 Linux 上的配置文件( .zshrc.bashrc等)中导出 JAVA_OPTS 或在 Windows 上永久添加为环境。


Then, you can type the flutter or sdkmanager command:然后,您可以输入 flutter 或 sdkmanager 命令:

Flutter :颤振

flutter doctor --android-licenses

sdkmanager : sdkmager :

sdkmanager --licenses

and type Y when needed to accept the licenses.并在需要时键入 Y 以接受许可证。

ps.附: This doesn't work for Java 11/11+, which doesn't have Java EE modules.这不适用于没有 Java EE 模块的 Java 11/11+。 For this option is a good idea, downgrade your Java version or wait for a Flutter update .对于此选项是个好主意,请降级您的 Java 版本或等待 Flutter更新

Ref: JDK 11: End of the road for Java EE modules参考: JDK 11:Java EE 模块之路的尽头

The right solution would be if you have android studio installed then正确的解决方案是,如果您安装了 android studio

  1. open SDK manager打开 SDK 管理器
  2. under SDK tools uncheck hide obsolete packages at the bottom在 SDK 工具下取消选中隐藏底部的过时包
  3. then you should see an option called Android SDK Tools (Obsolete)那么您应该会看到一个名为Android SDK Tools (Obsolete)的选项

在此处输入图片说明

  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完成后运行命令flutter doctor ,它现在应该会提示您运行flutter doctor --android-licenses运行许可证命令后按 y 接受所有许可证,它应该可以解决问题

在此处输入图片说明

I am writing this because of the frustration in installing flutter... Most issues are caused by simple configuration issues.我写这个是因为在安装 flutter 时遇到了挫折......大多数问题都是由简单的配置问题引起的。 Follow these steps to resolve your issues.请按照以下步骤解决您的问题。

STEP 1:ANDROID LICENSES --android-licenses, will resolve most cases第 1 步:ANDROID LICENSES --android-licenses,将解决大多数情况

Since you are here you have reached "Android License Status Unknown" issue for Android tool chain,as many suggested try flutter doctor --android-licenses .既然你在这里,你已经遇到了 Android 工具链的“Android 许可证状态未知”问题,许多人建议尝试flutter doctor --android-licenses If you are good with all the config.如果你对所有配置都很好。 It should ask for an yes and press y and Voila.它应该要求是,然后按 y 和 Voila。 But if it shows a但是如果它显示一个

在此处输入图片说明 Android sdkmanager tool not found (C\\Users\\__\\local\\Android\\sdk\\tools\\bin\\sdkmanager) .找不到 Android sdkmanager 工具(C\\Users\\__\\local\\Android\\sdk\\tools\\bin\\sdkmanager) Go to step two进入第二步

STEP 2: SDK Manager installation from Android Studio第 2 步:从 Android Studio 安装 SDK Manager

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.打开您的 Android Studio , File-> settings->System settings(left tab) ->Android SDK,转到该页面中的SDK Tool section ,取消选中隐藏过时的包,选择Android SDL tools(obsolete)并按应用。

在此处输入图片说明 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)它将安装 SDK,您通过检查此路径是否存在(C\\Users\\__\\local\\Android\\sdk\\tools\\bin\\sdkmanager)

STEP 3: Repeat 1第 3 步:重复 1

Repeat step 1 after installation in a new command line check if its working , else go to STEP 4在新的命令行中安装后重复步骤 1 检查其是否有效,否则转到步骤 4

STEP 4: sdkmanager --update第 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 .它会要求您更新 sdk,只需运行终端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,让它完成并重复步骤 1,否则如果它抛出一些异常,如java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema等, 错误 it means your java is not installed or not the correct version.这意味着您的java未安装或版本不正确。 Go to next step进入下一步

STEP 5: JAVA 8.1 and JAVA_HOME path.第 5 JAVA 8.1 和 JAVA_HOME 路径。

Install JAVA 8.1 and set JAVA_HOME path.安装 JAVA 8.1 并设置 JAVA_HOME 路径。 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确保它是8.1版本(注册免费帐户并从oracle下载8.1版本,记住11+以上不适用于flutter 在此处输入图片说明

NOTE : by yaniv maymon: if you already have Java installed on your computer and the sdkmanager --update still not working.注意:由yaniv maymon 提供:如果您的计算机上已经安装了 Java 并且 sdkmanager --update 仍然无法正常工作。 go the environment variable and update the "JAVA_HOME" path to jdk folder.转到环境变量并将“JAVA_HOME”路径更新到 jdk 文件夹。 then exit the command prompt, open it again and run the update command –然后退出命令提示符,再次打开并运行更新命令——

STEP 6: Final Step第 6 步:最后一步

After installing and setting up path properly, run the C\\Users\\__\\local\\Android\\sdk\\tools\\bin\\sdkmanager --update command in new terminal and it will work正确安装并设置好路径后,在新终端运行C\\Users\\__\\local\\Android\\sdk\\tools\\bin\\sdkmanager --update命令即可

STEP 7: Rerun flutter doctor , You can see it saying to run the command flutter doctor --android-licenses .步骤 7:重新运行 flutter doctor ,您可以看到它说运行命令flutter doctor --android-licenses so run flutter doctor --android-licenses in terminal and press y when asked所以在终端中运行flutter doctor --android-licenses并在询问时按 y

Here are the steps that solve my problem:以下是解决我的问题的步骤:

  1. Open your terminal打开你的终端
  2. type flutter doctor --android-licenses输入flutter doctor --android-licenses
  3. press y to accept, this process may occurred several times.y接受,此过程可能会发生多次。 Done!完成!

In my case the issue was missing Android SDK Command-line tools在我的情况下,问题是缺少Android SDK Command-line tools

在此处输入图片说明

I found this solution for having to use JDK 8 (you need an account to download now!) - use the embedded OpenJDK that comes with Android Studio:我找到了这个必须使用 JDK 8 的解决方案(您现在需要一个帐户才能下载!) - 使用 Android Studio 附带的嵌入式 OpenJDK:

Add this to your ~/.profile or similar:将此添加到您的~/.profile或类似文件中:

# 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+.通过gradlew和任何其他表现良好的脚本进行命令行构建,然后将使用 Android Studio 2.2+ 附带的 SDK 版本。

*My Mac was still using the default Java 7. *我的 Mac 仍在使用默认的 Java 7。

This was also my issue same as #16025这也是我的问题,与#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.对于线程“main”中的异常 java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema 这个问题似乎通常发生在您之前安装 Java 9 时。 BTW it's not compatible with android-sdk try to remove Java 9 JDK if still exist.顺便说一句,它与 android-sdk 不兼容,如果仍然存在,请尝试删除 Java 9 JDK。

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).一般来说,JAXB API 被认为是 Java EE API,因此不再包含在 Java SE 9 的默认类路径中。Java 9 引入了模块的概念,默认情况下 java.se 聚合模块在类中可用路径(或者更确切地说,模块路径)。 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.顾名思义,java.se 聚合模块不包括传统上与 Java 6/7/8 捆绑在一起的 Java EE API。 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.幸运的是,JDK 6/7/8 中提供的这些 Java EE API 仍在 JDK 中,只是默认情况下它们不在类路径中。 The extra Java EE APIs are provided in the following modules以下模块中提供了额外的 Java EE API

Solution to workaround if you have Java9/10 installed如果您安装了 Java9/10,解决方法

  1. Open sdkmanager in your editor.在编辑器中打开 sdkmanager。
  2. Append DEFAULT_JVM_OPTS附加 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:对于 Android 许可证状态未知问题,我尝试通过以下步骤解决:

  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转到您的 Android SDK 位置 C:\\Users%user%\\AppData\\Local\\Android\\Sdk\\tools\\bin 或 ~/Library/Android/sdk/tools/bin

  3. Run the command: ./sdkmanager --license运行命令:./sdkmanager --license

References参考文献

Failed to run sdkmanager --list (Android SDK) with Java 9 无法使用 Java 9 运行 sdkmanager --list (Android SDK)

How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9 如何解决 Java 9 中的 java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

here is my solution:这是我的解决方案:

  1. install SDKMan安装 SDKMan

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

  2. setting your bash_profile设置你的 bash_profile

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

    $ source ~/.bash_profile

  3. find java sdk, and select want to install version找到java sdk,选择要安装的版本

    $ sdk ls java

    $ sdk install java 8.0.192-zulu

  4. copy your flutter doctor warning message to update sdkmanager复制您的颤振医生警告消息以更新 sdkmanager

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

  5. after 1~4, redo it 1~4后重做

    $ flutter doctor --android-licenses

This line provided on GitHub issue community fixed my problem, here it is just in case it helps anyone else. 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%

Refer-- https://robbinespu.gitlab.io/blog/2020/03/03/flutter-issue-fixed-android-license-status-unknown-on-windows/参考-- 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所以这里是解决方案,打开您的 SDK 管理器,然后取消选中Hide Obsolete Packages

在此处输入图片说明

Now you'll see Android SDK Tools (Obsolete) 26.1.1 appears.现在您将看到Android SDK Tools (Obsolete) 26.1.1出现。 Tick that package and hit apply button then ok button.勾选那个包并点击apply button然后点击确定按钮。 it will download sdk.它会下载sdk。 then restart Android studio然后restart安卓工作室

Nice, now if you run flutter doctor , you should get positive result as below很好,现在如果你运行flutter doctor ,你应该得到如下的阳性结果

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运行flutter doctor --android-licenses并在询问时输入 Y

if needed we can download package manually here https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip (for Windows user).如果需要,我们可以在此处手动下载软件包https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip (适用于 Windows 用户)。 Hope this tutorial help people who looking for solution希望本教程可以帮助寻找解决方案的人

MacOS 10.15: Android Studio 3.5.1: 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 ).对我有用的解决方案是使用Java 环境工具jenv (通过homebrew安装)。 This tool changes the $JAVA_HOME when one switches between java versions.当在 Java 版本之间切换时,此工具会更改$JAVA_HOME

In my case I have multiple Java versions installed and the current global version in use was the default.就我而言,我安装了多个 Java 版本,当前使用的全局版本是默认版本。 I also found it necessary to comment out the $JAVA_HOME environment variable in my .bash_profile when using this tool.我还发现有必要在使用此工具时注释掉.bash_profile$JAVA_HOME环境变量。

In Terminal, I entered jenv global 1.8 to get java 1.8 running instead of a later version (I have multiple versions installed).在终端中,我输入jenv global 1.8来运行 java 1.8 而不是更高版本(我安装了多个版本)。

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_HOME 环境变量,您可能需要退出并重新打开终端 shell。

For those of you who are on Linux and keep getting errors during flutter doctor --android-licenses .对于那些使用 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:尝试接受许可证时,我不断收到无法创建设置警告,我通过指定 SDK 位置修复了该警告:

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

Sdkmanager then printed: all SDK package licenses accepted. Sdkmanager 然后打印:所有 SDK 包许可证都被接受。

However Flutter kept giving the android license status unknown error.但是 Flutter 一直给android 许可证状态未知错误。 And attempting to call flutter doctor --android-licenses would give me the same could not create settings error I used to get.并尝试调用flutter doctor --android-licenses会给我同样的无法创建我曾经得到的设置错误。

To fix this I edited the sdkmanager script located in ${your android tools location} /tools/bin/ and changed the last line from:为了解决这个问题,我编辑了位于${your android tools location} /tools/bin/ 的sdkmanager脚本,并将最后一行从:

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.这将使 Flutter 在传递所需的 sdk_root 参数时调用 sdkmanager,最后调用flutter doctor --android-licenses修复了该问题。

I did not have to use Java 8.我不必使用 Java 8。

open the flutter_console.bat file from the flutter SDK root folder and run the command从 flutter SDK 根文件夹打开 flutter_console.bat 文件并运行命令

flutter doctor --android-licenses

it will accept the licenses of newly downloaded updates of Android SDK.它将接受新下载的 Android SDK 更新的许可。 You need to run it every time whenever you download and update the Android SDK.每次下载和更新 Android SDK 时都需要运行它。

Try downgrading your java version , this will happen when your systems java version isn't compatible with the one from android.尝试降级您的 java 版本,当您的系统 java 版本与来自 android 的版本不兼容时,就会发生这种情况。 Once you changed you the java version just run flutter doctor it will automatically accepts the licenses.一旦您更改了 Java 版本,只需运行flutter doctor它将自动接受许可证。

I downgraded my Java version to 1.8 and its resolved, here is the link to download JDK8我将我的 Java 版本降级到 1.8 并已解决,这里是下载JDK8的链接

Run the following command after installing JDK8安装JDK8后运行以下命令

   flutter doctor --android-licenses

My environment : Windows 10 64bit, OpenJDK 14.0.2我的环境:Windows 10 64 位,OpenJDK 14.0.2

Initial errors are as reported above.初始错误如上所述。

Error was resolved after错误解决后

  1. Replaced " C:<installation-folder>\\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将环境变量 PATH & JAVA_HOME 中的“ C:<installation-folder>\\openjdk-14.0.2_windows-x64_bin\\jdk-14.0.2 ”替换为“* C:\\Program Files\\Android\\Android Studio\\jre*
  2. ran flutter doctor --android-licenses and selected y for the prompts运行flutter doctor --android-licenses并选择y作为提示

对我来说同样的问题,请检查您的 Java 版本至少必须是 1.8

  1. Open Android Studio.打开安卓工作室。
  2. Go to File->Settings.转到文件-> 设置。
  3. Search for AndroidSDK .搜索AndroidSDK
  4. Update your API Level to latest version.将您的 API 级别更新到最新版本。
  5. Then reload Android Studio.然后重新加载 Android Studio。

For someone who is still facing the issue :对于仍然面临问题的人
As answered below by Tommie C, Aba and few other people, but may not be clear enough as I found it.正如下面汤米 C、阿巴和其他少数人所回答的那样,但我发现的可能不够清楚。
Try installing java 1.8 manually as described here on windows/linux: [ https://www3.ntu.edu.sg/home/ehchua/programming/howto/JDK_Howto.html]尝试按照 windows/linux 上的说明手动安装java 1.8 :[ https://www3.ntu.edu.sg/home/ehchua/programming/howto/JDK_Howto.html]
and setting $JAVA_HOME variable(jdk path).并设置$JAVA_HOME变量(jdk 路径)。
On windows set jdk path($JAVA_HOME) : [ How to set java_home on Windows 7?在 Windows 上设置 jdk 路径($JAVA_HOME):[ 如何在 Windows 7 上设置 java_home? . .
On linux: [ https://askubuntu.com/questions/175514/how-to-set-java-home-for-java] .在 linux 上:[ https://askubuntu.com/questions/175514/how-to-set-java-home-for-java]
Then run flutter doctor --android-licenses and accept all the licenses.然后运行flutter doctor --android-licenses并接受所有许可证。 Hope it helps.希望它有帮助。

我找到了这个解决方案。我下载了JDK 8。然后我将JAVA_HOME的下载jdk文件路径名添加到环境变量中的用户变量中。

I faced the same problem, like mentioned above I tried these.我遇到了同样的问题,如上所述,我尝试了这些。

  1. Installed JDK 1.8 and set my JAVA_HOME env to 1.8 - This did not work安装了 JDK 1.8 并将我的 JAVA_HOME env 设置为 1.8 - 这不起作用
  2. My Android studio didn't show any "Android SDK Tools (Obsolete)" but had had an "Android SDK Tools"我的 Android 工作室没有显示任何“Android SDK 工具(过时)”但有一个“Android SDK 工具”

This is what worked for me:这对我有用:

  1. Delete the "Android SDK Tools" from SDK Manager从 SDK Manager 中删除“Android SDK Tools”
  2. Reinstall it by first deselecting the "Hide Obsolete Packages" and then select "Android SDK Tools (Obsolete)", install it.首先取消选择“Hide Obsolete Packages”,然后选择“Android SDK Tools (Obsolete)”,重新安装它。
  3. run flutter doctor --android-licenses and select y for the prompts运行flutter doctor --android-licenses并选择y作为提示
  4. run flutter doctor and everything will be fine!!!!运行flutter doctor ,一切都会好起来的!!!!

I was facing issue.我正面临问题。 The tools folder was also missing from the Android SDK folder. Android SDK文件夹中也缺少tools文件夹。 I believe tools folder appears only after installing Android SDL tools(obsolete ).我相信tools文件夹仅在安装Android SDL tools(obsolete )后才会出现。 This option was not available for me.这个选项对我不可用。

Solution: I upgraded the Java from version 8 to version 12 and I was able to install the tools.解决方案:我将Java从版本 8 升级到版本 12,并且能够安装这些工具。 You may still get the error Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses您可能仍会收到错误“ Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses while giving the command flutter doctor -v . Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses并提供命令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):运行命令flutter doctor --android-licenses ,每次出现此问题时单击yes都会检查许可证是否Accept? (y/N): Accept? (y/N):

Hopefully it will help someone.希望它会帮助某人。

If you use homebrew cask , you can do如果你使用自制酒桶,你可以这样做

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

For Windows people a short term solution is to downgrade to JDK8.对于Windows 用户,短期解决方案是降级到 JDK8。 Hopefully flutter will fix the issue soon for Android SDK to be working with >JDK8.希望 Flutter 能很快解决这个问题,让 Android SDK 与 >JDK8 一起工作。

After doing lots of analysis for my Ubuntu 20.04 I have found the solution在对我的 Ubuntu 20.04 进行大量分析后,我找到了解决方案

for me the error was /home/rk/Android/Sdk/tools/bin/sdkmanager was missing write permission.对我来说,错误是/home/rk/Android/Sdk/tools/bin/sdkmanager缺少写入权限。

  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.它会自动处理许可证。

Follow these simple steps.请按照以下简单步骤操作。

  1. go to tools, then SDK manager, then click on android SDK.转到工具,然后是 SDK 管理器,然后单击 android SDK。
  2. click SDK update sites tab.单击 SDK 更新站点选项卡。
  3. check the checkbox that states https://..sources to be fetched using https://.选中使用 https:// 获取 https://..sources 的复选框。
  4. click apply and ok.单击应用并确定。
  5. Now restart android studio.现在重新启动android studio。
  6. go to SDK tools and check the checkbox that states Hide obsolete packages.转到 SDK 工具并选中状态为隐藏过时包的复选框。
  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.然后选择一个名为“android SDK tools (obsolete)”的包,然后按确定。
  9. continue to install the package.继续安装包。
  10. after installation restart android studio and also restart cmd, then run flutter doctor.安装后重启android studio并重启cmd,然后运行flutter doctor。
  11. it will take a couple of minutes and it should work这将需要几分钟,它应该可以工作

Even in 2021, I faced the same problem with即使在 2021 年,我也面临同样的问题

  • Android Studio - Arctic fox 2020.3.1 Patch 2 Android Studio - 北极狐 2020.3.1 补丁 2
  • Java jdk-16.0.2 Java jdk-16.0.2
  • Android SDK Version 31.0.0安卓 SDK 版本 31.0.0
  • Flutter 2.5颤振 2.5

I have tried the answers above except for editing the sdkmanager.bat file.除了编辑 sdkmanager.bat 文件之外,我已经尝试了上面的答案。 But NO SUCCESS at all.但根本没有成功。

Then I upgraded flutter 2.5 to 2.5.1 using the "flutter upgrade" command.然后我使用“flutter upgrade”命令将flutter 2.5升级到2.5.1。 Now it is working.现在它正在工作。 NO issues with the "flutter doctor" command. “颤振医生”命令没有问题。

In linux:20.10 Please make sure you set up the path for ANDROID_HOME, ANDROID_SDK_ROOT link<\/a>在 linux:20.10 请确保您设置了 ANDROID_HOME、ANDROID_SDK_ROOT 链接<\/a>的路径

I have to update newest cmdline-tools:我必须更新最新的命令行工具:

path/to/sdkmanager --install "cmdline-tools;latest"

WARNING : This answer is useful if you have problems with JAVA_HOME environmental variable and the direction of that.警告:如果您对 JAVA_HOME 环境变量及其方向有问题,则此答案很有用。 If you do not have this problem, you should not try this solution.如果您没有此问题,则不应尝试此解决方案。

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.如果您遇到此错误并且您尝试使用 flutter doctor --android-licenses 或 sdkmanager --licenses 并且您的 JAVA_HOME 环境变量出现问题,那么您必须阅读此内容。

I have a MacOS Catalina ant I could resolve this problem successfully with the next steps:我有一个 MacOS Catalina 蚂蚁,我可以通过以下步骤成功解决这个问题:

  1. Open your terminal打开你的终端
  2. Type: open -e .bash_profile (You should see almost two environmental variables: flutter and JAVA_HOME)输入:open -e .bash_profile(你应该会看到几乎两个环境变量:flutter 和 JAVA_HOME)
  3. Save JAVA_HOME environmental variable written there in a textEdit file if you wish and DELETE the JAVA_HOME environmental variable.如果您愿意,可以将 JAVA_HOME 环境变量保存在 textEdit 文件中,然后删除 JAVA_HOME 环境变量。 Save the bash_profile.保存 bash_profile。
  4. Go to terminal again and run source $HOME/.bash_profile再次进入终端并运行 source $HOME/.bash_profile
  5. Try again flutter doctor and you shouldn't see the same error any more.再试一次 flutter doctor ,你应该不会再看到同样的错误了。

Please, let me know if you have doubts.如果您有疑问,请告诉我。

Here's what I did to fix my issue.这是我为解决问题所做的工作。 Please note that, you don't have to uninstall your old copy of Android Studio/SDK.请注意,您不必卸载旧的 Android Studio/SDK 副本。 Android Studio will take care of that whilst you are installing the latest version. Android Studio 会在您安装最新版本时处理这些问题。

  1. Downloaded & install the latest version of Android Studio下载并安装最新版本的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.安装完成后,运行flutter doctor并检查,你的问题应该已经解决了。 If the issue is resolved, there's no need to run the flutter doctor --android-licenses command.如果问题得到解决,则无需运行flutter doctor --android-licenses命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM