Gradle,您尚未接受许可协议(Android SDK)

use*_*522 5 android gradle

是的,我知道有很多关于这个主题的帖子,但我尝试过的都不起作用。

我是在 Windows 上从命令行运行 Gradle,而不是从 Android Studio 执行此操作。

我刚刚删除了以前的Android SDK文件夹,下载了最新的Android SDK,并安装到C:\android-sdk

然:

sdkmanager "platform-tools" "build-tools;28.0.3"    "platforms;android-26" "platforms;android-28"
Run Code Online (Sandbox Code Playgroud)

然后跑:

sdkmanager --licenses 
Run Code Online (Sandbox Code Playgroud)

并接受每个许可证及其响应:接受所有 SDK 包许可证

然后我运行:

C:\Dev>SET ANDROID_HOME=C:/android-sdk&&SET PATH=C:/gradle-4.0/bin;%PATH%&&SET JAVA_HOME=C:/Program Files/Java/jdk1.8.0_31&&cd C:/Android/dev/ProgramName&&gradle clean
Run Code Online (Sandbox Code Playgroud)

并得到这个错误:

> You have not accepted the license agreements of the following SDK components:
[Android SDK Build-Tools 28.0.3, Android SDK Platform 28].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Run Code Online (Sandbox Code Playgroud)

ANDROID_HOME 设置为 SDK 目录。我尝试过使用不同的 Gradle 版本进行构建。删除许可证目录并重新运行“sdkmanager --licenses”

大多数现有的“解决方案”已有数年历史,其中许多是针对 Linux 命令行的。

由于这似乎是在 Gradle 构建中发生的,是否有任何 Gradle 选项可能有帮助?

我确实安装了多个 Android SDK,另一个位于 C:\Program Files\android-sdk-windows 中,但 ANDROID_HOME 设置为我尝试使用的 SDK 目录。

我以前遇到过这个问题并且能够解决它,但我不记得我做了什么,它似乎与较新的平台有关;android-28。

更新:

这很重要的一个原因是,Play 商店将要求应用程序在 8 月份之前将目标 API 设为 28,这就是我尝试进行此构建的原因。

刚刚尝试过,在“build-tools;28.0.3”和“platform;android-28”上做了--uninstall,只留下platform;android-26,并安装了“build-tools;28.0.2”,重新做了sdkmanager --licenses 现在它只收到错误:

> You have not accepted the license agreements of the following SDK components:
  [Android SDK Build-Tools 28.0.2].
Run Code Online (Sandbox Code Playgroud)

谢谢!

Yev*_*nii 0

您应该接受许可协议。

  1. 在$ANDROID_HOME/tools/bin中找到 SDK 管理器。
  2. 运行 sdkmanager:在 Windows 上运行sdkmanager --licenses ,在 Linux 上运行 ./sdkmanager --licenses
  3. 接受您需要的许可证。