解决 Failed to install the following Android SDK packages as some licences have not been accepted

yufei       5 年, 7 月 前       26581

如果你没有使用 Android Studio 而是直接安装了 Android SDK,那么第一次使用的时候,应该是会报错的。

比如我使用 React Native 开发的时候就出现了下面这个错误

info Starting JS server...
info Building and installing the app on the device (cd android && ./gradlew app:installDebug)...

> Configure project :app
Checking the license for package Android SDK Build-Tools 28.0.3 in /usr/local/Caskroom/android-platform-tools/28.0.1/licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 28 in /usr/local/Caskroom/android-platform-tools/28.0.1/licenses
Warning: License for package Android SDK Platform 28 not accepted.

FAILURE: Build failed with an exception.

* What went wrong:
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: /usr/local/Caskroom/android-platform-tools/28.0.1

* 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 0s
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have

一段长长的信息输出,而真正的错误,是下面这句话

> 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

这个错误也是很坑的,因为我们肯定是办法使用 Android Studio 的,那,要如何解决呢?

很简单,在命令行里输入

sdkmanager --licenses

然后就有一大堆的 license 等着你输入 yes

如果不想每次都输入 yes 那么只需要运行下面的命令

yes | sdkmanager --licenses
2 回复  |  直到 Sep 25, 2019

15323415173

#1   •   5 年, 2 月 前   •  

你好,我输入sdkmanager --licenses命令提示我‘SDK’不是内部或外部命令也不是可运行的程序什么原因呢

yufei

#2   •   5 年, 1 月 前   •  

@15323415173 因为你的 sdkmanager 没有在 PATH 路径中

简单教程 = 简单教程,简单编程
简单教程 是一个关于技术和学习的地方
现在注册
已注册用户请 登入
关于   |   FAQ   |   我们的愿景   |   广告投放   |  博客

  简单教程,简单编程 - IT 入门首选站

Copyright © 2013-2022 简单教程 twle.cn All Rights Reserved.