gpt4 book ai didi

Flutter 无法识别 Android SDK 构建工具 25.0.3

转载 作者:IT老高 更新时间:2023-10-28 12:46:25 27 4
gpt4 key购买 nike

文科,刚开始看Flutter,在Android Studio 3.0.1安装Flutter插件,重启Android Studio,根据Flutter文档创建了一个简单的hello world app。

这还在 C:\flutter 中安装了 Flutter SDK,因此应用创建过程正确选择了该位置作为 SDK 位置。

但是,运行应用程序(在模拟器上)时,会显示此错误

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Finished with error:

* Error running Gradle:
Unable to download needed Android SDK components, as the following licenses have not been accepted:
Android SDK Build-Tools 25.0.3

To resolve this, please run the following command in a Terminal:
flutter doctor --android-licenses

但是当我查看 Android SDK 时,安装了从 25.0.0 到 27.0.1 的每个构建工具,包括 25.0.3。

按照上面的建议从终端运行 flutter doctor --android-licenses 显示此错误

C:\Users\user\Desktop\work\flutter\first_flutter_app>doctor --android-licences
'flutter' is not recognized as an internal or external command,
operable program or batch file.

更新

然后我将我的 C:\flutter\bin 添加到系统路径并再次尝试发布

flutter doctor --android-licenses

但出现错误“Unknown argument --licenses”。

接下来我运行:

flutter upgrade

这也已完成,但运行我的应用程序仍然会产生与许可证问题相同的错误。

flutter upgrade 显示以下输出:

Running flutter doctor...
[√] Flutter (on Microsoft Windows [Version 10.0.15063], locale en-US, channel alpha)
• Flutter at C:\flutter
• Framework revision d957c8f040 (4 days ago), 2017-11-30 13:29:59 -0800
• Engine revision 77d8acb9be
• Tools Dart version 1.25.0-dev.11.0
• Engine Dart version 2.0.0-dev.9.0

[√] Android toolchain - develop for Android devices (Android SDK 25.0.2)
• Android SDK at C:\Program Files (x86)\Android\android-sdk
• Unable to locate Android NDK.

• Unable to locate compiler in Android NDK.

• Platform android-25, build-tools 25.0.2
• ANDROID_HOME = C:\Program Files (x86)\Android\android-sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[√] Android Studio (version 3.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[√] Connected devices
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 7.1.1 (API 25) (emulator)

我真的一直在绕圈子。这是当我使用 flutter 从终端运行我的应用程序时发生的情况(上面我解释了如果我从 IDE 运行它会发生什么:

C:\Users\user\Desktop\work\flutter\flutter_app_myapp>flutter run
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle... 0.7s
Resolving dependencies... |

* Error running Gradle:
Unable to download needed Android SDK components, as the following licenses have not been accepted:
Android SDK Build-Tools 25.0.3

To resolve this, please run the following command in a Terminal:
flutter doctor --android-licenses /
C:\Users\user\Desktop\work\flutter\flutter_app_myapp>>flutter doctor --android-licenses
Error: Unknown argument --licenses

更新 2

flutter -v doctor --android-licenses 的输出

C:\Users\user\Desktop\work\flutter\flutter_app_dino>flutter -v doctor --android-licenses
[ +23 ms] [C:\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
[ +45 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[ ] origin/alpha
[ ] [C:\flutter\] git rev-parse --abbrev-ref HEAD
[ +20 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[ ] alpha
[ ] [C:\flutter\] git ls-remote --get-url origin
[ +19 ms] Exit code 0 from: git ls-remote --get-url origin
[ ] https://github.com/flutter/flutter.git
[ ] [C:\flutter\] git log -n 1 --pretty=format:%H
[ +20 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[ ] d957c8f040902aa3fd44b367150bde56b64cec83
[ ] [C:\flutter\] git log -n 1 --pretty=format:%ar
[ +21 ms] Exit code 0 from: git log -n 1 --pretty=format:%ar
[ ] 5 days ago
[ +222 ms] C:\Program Files (x86)\Android\android-sdk\tools\bin\sdkmanager.bat --licenses
**Error: Unknown argument --licenses**
Usage:
sdkmanager [--uninstall] [<common args>] \
[--package_file <package-file>] [<packages>...]
sdkmanager --update [<common args>]
sdkmanager --list [<common args>]

In its first form, installs, or uninstalls, or updates packages.
<package> is a sdk-style path (e.g. "build-tools;23.0.0" or
"platforms;android-23").
<package-file> is a text file where each line is a sdk-style path
of a package to install or uninstall.
Multiple --package_file arguments may be specified in combination
with explicit paths.
In its second form (with --update), currently installed packages are
updated to the latest version.
In its third form, all installed and available packages are printed out.

Common Arguments:
--sdk_root=<sdkRootPath>: Use the specified SDK root instead of the SDK containing this tool
--channel=<channelId>: Include packages in channels up to <channelId>.
Common channels are:
0 (Stable), 1 (Beta), 2 (Dev), and 3 (Canary).

--include_obsolete: With --list, show obsolete packages in the
package listing. With --update, update obsolete
packages as well as non-obsolete.
--no_https: Force all connections to use http rather than https.
--proxy=<http | socks>: Connect via a proxy of the given type.
--proxy_host=<IP or DNS address>: IP or DNS address of the proxy to use.
--proxy_port=<port #>: Proxy port to connect to.

* If the env var REPO_OS_OVERRIDE is set to "windows",
"macosx", or "linux", packages will be downloaded for that OS.
[ +152 ms] "flutter doctor" took 301ms.
[ +198 ms] ensureAnalyticsSent: 196ms
[ +2 ms] exiting with code 0

但是,如果我导航到我的 Android\sdk\tools\bin,我确实有 sdkmanager 并从那里发出 sdkmanager --licenses 显示:

C:\Users\user\AppData\Local\Android\sdk\tools\bin>sdkmanager --licenses
All SDK package licenses accepted.======] 100% Computing updates...

因此,目前看来 Flutter 充满了错误,不确定是否值得在这个 alpha 阶段花时间研究它,如您所见,我有几个循环问题,它说找不到命令,但命令存在。我遵循了准确的安装步骤,如果花了好几天时间才弄清楚,但仍然没有解决方案,我会说,它还没有准备好。

最佳答案

运行 flutter doctor 时出现此错误的原因是您没有将 flutter.bat 位置文件放入 PATH(Windows 环境变量)中。或者 flutter 搞砸了。
假设您不想这样做,只需将 flutter 称为 "$FLUTTER_DIR\bin\flutter"doctor --android-licences

关于Flutter 无法识别 Android SDK 构建工具 25.0.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47581151/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com