这里我要做的是使用VS代码构建我的flutter应用程序。当我运行以下命令flutter build apk
时
FAILURE: Build failed with an exception.
* Where:
Build file 'F:year-03SEM2eventsGSOCLabelLablabellab_mobileandroidbuild.gradle' line: 27
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
platforms;android-28 Android SDK Platform 28
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: C:UsersMr.SemicolonAppDataLocalAndroidsdk
为了理解确切的解决方案,我将描述在VS Code IDE中设置Flutter所遵循的所有步骤
1.从下载Flutter Windows SDKhttps://flutter.dev
2.将文件提取到C驱动器
3。转到文件路径C:flutterbin
并设置环境变量
4.在VS Code IDE中安装Flutter和Dart扩展
5.使用flutter build apk
运行应用程序
编辑:flutter doctor
输出,
[√] Flutter (Channel stable, v1.12.13+hotfix.9, on Microsoft Windows [Version 10.0.18362.720], locale en-GB)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
X Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed instructions.
[!] Android Studio (version 3.6)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[!] IntelliJ IDEA Ultimate Edition (version 2019.3)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[√] VS Code (version 1.44.0)
[!] Connected device
! No devices available
此错误是由于缺少许可协议
打开您的终端flutter doctor --android-licenses
按y
接受每个许可证。
在某些机器中,您需要以管理员身份打开命令提示符。因此,您可以尝试以下步骤并检查
- 以管理员身份执行命令提示符
- 运行命令
flutter doctor --android-licenses
并接受全部。按Y即可获得许可证 - 运行命令
flutter doctor -v
检查问题是否仍然存在 - 以常规用户身份登录并尝试
flutter doctor -v
以确保一切正常
如果它仍然给您带来相同的问题,请访问您的flutter文件夹,打开名为flatter_console.bat的文件,然后键入此命令flutter doctor --android-licenses
。