【问题标题】:VS Code: Failed to install the following Android SDK packages as some licences have not been acceptedVS Code: 未能安装以下 Android SDK 包,因为某些许可证尚未被接受
【发布时间】:2020-07-27 02:08:01
【问题描述】:

我正在尝试使用 VS Code 构建我的颤振应用程序。当我运行以下命令时flutter build apk

FAILURE: Build failed with an exception.

* Where:
Build file 'F:\year-03\SEM2\events\GSOC\LabelLab\labellab_mobile\android\build.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:\Users\Mr.Semicolon\AppData\Local\Android\sdk

为了了解确切的解决方案,我将描述我在 VS Code IDE 中设置 Flutter 所遵循的所有步骤。
1. 从https://flutter.dev下载 Flutter Windows SDK
2.解压文件到C盘
3.进入文件路径C:\flutter\bin,设置环境变量。
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

【问题讨论】:

标签: android flutter dart visual-studio-code build


【解决方案1】:

此错误是由于缺少许可协议。

打开你的终端。
flutter doctor --android-licenses
y 接受每个许可证。

【讨论】:

  • 感谢答案,但它在线程“main”java.lang.NoClassDefFoundError 中给出错误异常:
  • 你直接在vs code终端执行了这个命令吧?此外,请检查项目中是否有 mainActivity 文件。
  • 我认为stackoverflow.com/questions/43574426/…应该是这样,但仍然不知道如何解决它
  • @IndrajithEkanayake 哥们,你得到了答案还是仍然停留在两者之间?
【解决方案2】:

在某些机器中,您需要以管理员身份打开命令提示符。因此,您可以尝试以下步骤并检查

  • 以管理员身份执行命令提示符
  • 运行命令flutter doctor --android-licenses 并全部接受。 按 Y 获得许可。
  • 运行flutter doctor -v命令查看问题是否依然存在;
  • 以普通用户身份登录并尝试flutter doctor -v 以确保一切正常。

如果它仍然给您同样的问题,请访问您的 flutter 文件夹并打开名为 flutter_console.bat 的文件并输入此命令 flutter doctor --android-licenses

【讨论】:

猜你喜欢
  • 2019-06-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-08
  • 2021-11-04
  • 1970-01-01
相关资源
最近更新 更多