Android/Sdk 缺少 Tools 文件夹,意味着没有 sdkmanager,意思是“Android 许可证状态未知”错误

Joe*_*ano 2 android gradle android-studio android-sdk-manager flutter

我想开始学习 Flutter,所以我正在遵循指南,但我已经陷入了第一步。除了创建一个全新的应用程序之外,我什么也没做,但是当我在 Android Studio 中点击“运行”时,出现以下错误:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> 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: /home/greg/Android/Sdk

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Finished with error: Gradle task assembleDebug failed with exit code 1
Run Code Online (Sandbox Code Playgroud)

看着有类似问题的人,最常见的解决方案似乎是 running yes | ~/Android/tools/bin/sdkmanager --licenses,但我没有名为 sdkmanager 的文件夹或文件。我的整个文档树实际上是不同的,尽管我刚刚完成了 Ubuntu 的官方 Android Studio 下载过程。对于我的文档结构,我有

~/Android/Sdk/$ ls
build-tools  patcher    platform-tools  sources
emulator     platforms  skins  
Run Code Online (Sandbox Code Playgroud)

其中没有一个包含工具、bin 或 sdkmanager。

我还在 Android Studio 中打开了 SDK Manager,然后转到 SDK Tools 选项卡并更新 Build-Tools 并接受许可,然后退出并重新打开 Android Studio,但我遇到了同样的错误。我找不到与我具有相同文件结构的人。有谁知道我能做什么?

编辑

我开始认为真正的问题是我的 Android 文件夹的内容。当我跑步时,flutter doctor我收到此消息

[?] Flutter (Channel stable, v1.12.13+hotfix.8, on Linux, locale en_US.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 29.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.dev/setup/#android-setup for detailed instructions.
[!] Android Studio (version 3.6)
    ? Flutter plugin not installed; this adds Flutter specific functionality.
    ? Dart plugin not installed; this adds Dart specific functionality.
[?] IntelliJ IDEA Community Edition (version 2019.3)
[!] Connected device
    ! No devices available

! Doctor found issues in 3 categories.
Run Code Online (Sandbox Code Playgroud)

但是当我运行时,flutter doctor --android-licences我收到以下错误消息:

Android sdkmanager tool not found (/home/greg/Android/Sdk/tools/bin/sdkmanager).
Try re-installing or updating your Android SDK,
visit https://flutter.dev/setup/#android-setup for detailed instructions.
Run Code Online (Sandbox Code Playgroud)

我实际上没有工具文件夹、bin 或 sdkmanager。我确实尝试卸载并重新安装 Android Studio,但没有任何改变。我下载了错误的包还是什么?我是直接从https://developer.android.com/studio/#downloads下载的,怎么可能内容不正确?我有 100GB 可用空间,所以空间限制并没有阻止它被安装。我也没有任何互联网问题。

小智 7

我在 MacOS 上也面临同样的问题。

我今天刚刚下载了 Android Studio (android-studio-ide-192.6241897-mac) 并且 /tools 文件夹对我来说也不见了。

我可以在“Android/”目录中看到“sdkmanager”的唯一方法是安装 cmdline-tools 并在 bin 文件夹中找到它。但这并不能解决问题。

编辑

找到了解决办法。显然,最新的 Android Studion 版本中不存在“tools/”文件夹。

您仍然可以使用 Android Studio 中的 SDK 管理器安装 SDK 工具。

打开 SDK 管理器并转到“SDK 工具”选项卡。在底部取消选中“隐藏过时的包”复选框。

执行此操作后,将出现安装“Android SDK 工具(过时)”软件包的选项。

安装它们并flutter doctor再次运行。它在接受许可证后工作


Ric*_*ood 5

在 Ubuntu 20.04 LTS 上,这些是我解决此问题的步骤

  1. 更新到最新版本的Android Studio(当前为4.0.1)。我正在使用JetBrains 工具箱应用程序在 Ubuntu 上安装 Android studio。

  2. 通过 snap 安装 flutter:

sudo snap install flutter --classic
sudo snap install flutter-gallery
flutter channel dev
flutter upgrade
flutter config --enable-linux-desktop
Run Code Online (Sandbox Code Playgroud)
  1. 按照下图安装命令行工具并在 Android Studio 中接受它们的许可证(见下图)

  2. 使用 flutter doctor 接受许可证

flutter doctor --android-licenses 5 of 6 SDK 包许可证不
公认。100% 计算更新...         
审查许可证
尚未被接受(是/否)?y

第三步:按照图片安装命令行工具:

  • 3.1 在 Android Studio 中选择命令行工具(最新),如图所示,按OK

Android SDK 命令行工具

  • 3.2 接受许可协议 许可协议

  • 3.3 确认变更 确认变更

  • 3.4 点击完成 单击“完成”