Flutter Doctor中的"Android许可证状态未知" [英] “Android license status unknown” in flutter doctor
问题描述
在命令行上运行flutter doctor
时,Android Sdk出现错误
I am getting an error with Android Sdk when I run flutter doctor
on command-line
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.
在遵循了stackoverflow社区的一些可能的修复程序之后,我仍然无法使它正常工作. 请帮助我.
After following several possible fixes from the stackoverflow community, i still couldn't get it to work. Please i need assistance.
推荐答案
这是对我有用的
- 启动Android Studio&打开SDK管理器(Android Studio的右上角)
- 导航至"SDK"选项卡,然后查找Android SDK平台工具
- 如果已选中,请取消选中它,然后单击应用"(我们正在尝试卸载以前的版本)
- 现在已卸载"SDK工具".让我们重新安装它,方法是选中相应的框并点击应用"
- 打好&重新启动Android Studio
- 在Windows的
%USERPROFILE%\AppData\Local\Android\Sdk
导航到SDK安装位置,您应该看到一个新文件夹tools
注意:如果您没有看到tools
文件夹没有出现紧急情况,那么我会让您满意. - 打开
tools
文件夹&导航到bin
- 复制文件夹路径(即
C:\Users\USERNAME%\AppData\Local\Android\Sdk\tools\bin
) - 将该路径添加到环境变量中
- 现在,您应该可以在命令行中访问
sdkmanager
.输入sdkmanager
&按Enter键进入CMD. - 如果得到
'sdkmanager' is not recognized as an internal or external command, operable program or batch file.
,则在将路径添加到系统环境变量时可能犯了一个错误.解决这个问题. - 转到Flutter sdk文件夹(即
c:/src/flutter
)&启动flutter_console.bat
文件 - 现在键入命令
flutter doctor --android-licenses
,它应该可以工作.键入y
并按ENTER 接受所有内容
- 别忘了运行
flutter doctor
- Launch Android studio & Open the SDK manager (Top-right of Android studio)
- Navigate to SDK Tab and look for 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. Let's re-install it by checking the box and clicking 'Apply'
- Hit Ok & Restart Android studio
- Navigate to SDK install location at
%USERPROFILE%\AppData\Local\Android\Sdk
for windows, you should see a new foldertools
Note: If you don't see thetools
folder don't panic, i got you covered. - Open the
tools
folder & navigate tobin
- Copy the folder path (i.e
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. Try it out by typingsdkmanager
& hitting enter in CMD. - If you get
'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 (i.e
c:/src/flutter
) & launch theflutter_console.bat
file - Now type the command
flutter doctor --android-licenses
and it should work. Accept all by typingy
and hitting ENTER - And don't forget to run
flutter doctor
PS:仅当Fix 1对您不起作用时!
- 打开浏览器& goto 仅命令行工具(页面底部)
- 下载适合您平台的软件包
- 解压缩&是的!您应该看到
tools
文件夹 -
提取后,将
tools
文件夹复制到C:\Users\USERNAME%\AppData\Local\Android\Sdk
- 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 After extraction, copy the
tools
folder toC:\Users\USERNAME%\AppData\Local\Android\Sdk
现在与上面的修订1相同,
打开tools
文件夹&导航到bin
Open the tools
folder & navigate to bin
- 执行Fix 2中的所有操作
- 打开环境变量,创建一个新变量
JAVA_HOME
并将其值设置为JRE/bin(从程序文件"中的Android Studio安装位置获取) - 打开Windows&的命令行类型
set JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
.export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
对于Linux
- Do everything in 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) - 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
就是这样,您现在可以在命令行上运行flutter doctor --android-licenses
了;键入y
并按Enter,以接受所有许可证.并且不要忘记运行flutter doctor
And that's it you can now run flutter doctor --android-licenses
on the command-line; Accept all licenses by typing y
and hitting ENTER. And don't forget to run flutter doctor
这篇关于Flutter Doctor中的"Android许可证状态未知"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!