首页 > 解决方案 > 如何在运行 --android-licenses 后更正此错误“错误:无法找到或加载主类”

问题描述

运行后我一直收到此错误flutter doctor --android-licenses我安装了所有 sdk 工具也我运行了flutter clean并且flutter build 我将 sdk 平台路径添加到 env 变量
这是我的flutter doctor --android-licenses输出:

Error: Could not find or load main class USERNAME\AppData\Local\Android\Sdk\cmdline-tools\latest\bin\\..

这是我的flutter doctor -v输出:

[√] Flutter (Channel master, 2.3.0-17.0.pre.47, on Microsoft Windows [Version
10.0.19041.985], locale en-CA)
• Flutter version 2.3.0-17.0.pre.47 at C:\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision fdb1fb184d (6 days ago), 2021-05-24 22:04:02 -0700
• Engine revision b1385c0df1
• Dart version 2.14.0 (build 2.14.0-145.0.dev)

[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc4)
    • Android SDK at C:\Users\USERNAME\AppData\Local\Android\Sdk
    • Platform android-30, build-tools 31.0.0-rc4
    • ANDROID_HOME = C:\Users\houda bouhsiss\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more
      details.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.2.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.212
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 90.0.818.66

! Doctor found issues in 1 category.






 

标签: flutterandroid-studio

解决方案


我通过重新安装/安装来修复它Android SDK Command-line Tools

更多信息:

https://stackoverflow.com/a/67720572/14058016


推荐阅读