简体   繁体   English

flutter doctor 中的“Android 许可证状态未知”

[英]“Android license status unknown” in flutter doctor

I am getting an error with Android Sdk when I run flutter doctor on command-line当我在命令行上运行flutter doctor时,Android Sdk 出现错误

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.4.9-hotfix.1, on Mac OS X 10.14.4 18E226, locale zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    ✗ Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit
      https://flutter.io/setup/#android-setup for detailed instructions.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2)
[✓] Android Studio (version 3.3)
[✓] VS Code (version 1.33.1)
[!] Connected device
    ! No devices available

! Doctor found issues in 2 categories.

After following several possible fixes from the stackoverflow community, i still couldn't get it to work.在遵循 stackoverflow 社区的几个可能的修复程序之后,我仍然无法让它工作。 Please i need assistance.请我需要帮助。

Here's what worked for me这对我有用

Fix 1:修复 1:

  • Launch Android studio & Open the SDK manager (Top-right of Android studio)启动 Android Studio 并打开 SDK 管理器(Android Studio 的右上角)
  • Navigate to SDK Tab and look for Android SDK Platform-Tools导航到 SDK 选项卡并查找 Android SDK Platform-Tools
  • If it's checked, unchecked it and click 'Apply' (We're trying to uninstall the previous version)如果已选中,请取消选中它并单击“应用”(我们正在尝试卸载以前的版本)
  • Now the "SDK Tools" is uninstalled.现在“SDK 工具”已卸载。 Let's re-install it by checking the box and clicking 'Apply'让我们通过选中该框并单击“应用”来重新安装它
  • Hit Ok & Restart Android studio点击确定并重新启动 Android 工作室
  • Navigate to SDK install location at %USERPROFILE%\\AppData\\Local\\Android\\Sdk for windows, you should see a new folder tools Note: If you don't see the tools folder don't panic, i got you covered.对于 Windows,导航到%USERPROFILE%\\AppData\\Local\\Android\\Sdk SDK 安装位置,您应该会看到一个新的文件夹tools注意:如果您没有看到tools文件夹,请不要惊慌,我已经涵盖了您。
  • Open the tools folder & navigate to bin打开tools文件夹并导航到bin
  • Copy the folder path (ie C:\\Users\\USERNAME%\\AppData\\Local\\Android\\Sdk\\tools\\bin )复制文件夹路径(即C:\\Users\\USERNAME%\\AppData\\Local\\Android\\Sdk\\tools\\bin
  • Add that path to Environmental variables将该路径添加到环境变量
  • Now you should have access to sdkmanager in the command-line.现在您应该可以在命令行中访问sdkmanager Try it out by typing sdkmanager & hitting enter in CMD.通过键入sdkmanager并在 CMD 中按sdkmanager尝试一下。
  • If you get 'sdkmanager' is not recognized as an internal or external command, operable program or batch file.如果您得到'sdkmanager' is not recognized as an internal or external command, operable program or batch file. you probably made a mistake while adding the path to System Environmental Variables.您可能在添加系统环境变量的路径时犯了一个错误。 Fix that.解决这个问题。
  • Go to Flutter sdk folder (ie c:/src/flutter ) & launch the flutter_console.bat file转到 Flutter sdk 文件夹(即c:/src/flutter )并启动flutter_console.bat文件
  • Now type the command flutter doctor --android-licenses and it should work.现在输入命令flutter doctor --android-licenses ,它应该可以工作了。 Accept all by typing y and hitting ENTER通过键入y并按 ENTER 接受所有
  • And don't forget to run flutter doctor并且不要忘记运行flutter doctor

Fix 2:修复 2:

PS: Only if Fix 1 does not work for you! PS:仅当 Fix 1 对您不起作用时!

  • Open your browser & goto Command line tools only (bottom of the page)打开浏览器并转到命令行工具(页面底部)
  • Download the appropriate package for your platform下载适合您平台的软件包
  • Unzip it & Yes!解压,是的! You should see the tools folder您应该会看到tools文件夹
  • After extraction, copy the tools folder to C:\\Users\\USERNAME%\\AppData\\Local\\Android\\Sdk解压后,将tools文件夹复制到C:\\Users\\USERNAME%\\AppData\\Local\\Android\\Sdk

    Now the same as Fix 1 above,现在与上面的修复 1 相同,

  • Open the tools folder & navigate to bin打开tools文件夹并导航到bin

  • Copy the folder path (ie C:\\Users\\USERNAME%\\AppData\\Local\\Android\\Sdk\\tools\\bin )复制文件夹路径(即C:\\Users\\USERNAME%\\AppData\\Local\\Android\\Sdk\\tools\\bin
  • Add that path to Environmental variables将该路径添加到环境变量
  • Now you should have access to sdkmanager in the command-line.现在您应该可以在命令行中访问sdkmanager Try it out by typing sdkmanager & hitting enter in CMD.通过键入sdkmanager并在 CMD 中按sdkmanager尝试一下。
  • If you get 'sdkmanager' is not recognized as an internal or external command, operable program or batch file.如果您得到'sdkmanager' is not recognized as an internal or external command, operable program or batch file. you probably made a mistake while adding the path to System Environmental Variables.您可能在添加系统环境变量的路径时犯了一个错误。 Fix that.解决这个问题。
  • NO you're not done不,你还没有完成
  • The SDK Platform tools you downloaded is probably outdated (as you can see when you run the sdkmanager command from the command-line)您下载的 SDK 平台工具可能已经过时(从命令行运行sdkmanager命令时可以看到)
  • Now let's handover to Android Studio to do the rest.现在让我们把剩下的交给 Android Studio 来做。 Restart Android Studio, so it can recognize the tools folder you added.重新启动 Android Studio,以便它可以识别您添加的tools文件夹。
  • After Restart, Android Studio should automatically detect the outdated Platform-tools and prompt you to update (You must be connected to the internet!).重启后,Android Studio 应该会自动检测过时的 Platform-tools 并提示您更新(您必须连接到互联网!)。
  • IF UPDATE PROMPT DOES NOT SHOW UP如果更新提示没有出现
  • Open SDK Manager in Android studio,在 Android Studio 中打开 SDK Manager,
  • Go to UPDATES转到更新
  • Click Check Now单击Check Now
  • And you should get the PROMPT to update Platform-Tools你应该得到提示来更新平台工具

Fix 3:修复 3:

  • Do everything in Fix 2在 Fix 2 中完成所有操作
  • Open Environmental Variables, Create a new Variable JAVA_HOME and set the value to the JRE/bin (get it from Android studio install location in Program Files)打开环境变量,创建一个新的变量JAVA_HOME并将值设置为 JRE/bin(从程序文件中的 Android Studio 安装位置获取)
  • Open the command line type set JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee' for windows & export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee' for Linux打开命令行类型set JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee' for windows & export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee' for Linux

And that's it you can now run flutter doctor --android-licenses on the command-line;就是这样,您现在可以在命令行上运行flutter doctor --android-licenses Accept all licenses by typing y and hitting ENTER.通过键入y并按 ENTER 接受所有许可证。 And don't forget to run flutter doctor并且不要忘记运行flutter doctor

THAT'S THE FIX.这就是解决办法。 I HOPE IT WORKS FOR YOU TOO我希望它也适合你

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

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