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

问题描述:

执行gradle tasks报错: 

gradle tasks

> Configure project :app 
Exception while marshalling /usr/local/android-home/android-sdk-linux/build-tools/28.0.3/package.xml. Probably the SDK is read-only
Exception while marshalling /usr/local/android-home/android-sdk-linux/build-tools/29.0.2/package.xml. Probably the SDK is read-only
Exception while marshalling /usr/local/android-home/android-sdk-linux/platform-tools/package.xml. Probably the SDK is read-only
Exception while marshalling /usr/local/android-home/android-sdk-linux/platforms/android-26/package.xml. Probably the SDK is read-only
Exception while marshalling /usr/local/android-home/android-sdk-linux/platforms/android-27/package.xml. Probably the SDK is read-only
Exception while marshalling /usr/local/android-home/android-sdk-linux/tools/package.xml. Probably the SDK is read-only

> Configure project :picture_library 
Exception while marshalling /usr/local/android-home/android-sdk-linux/build-tools/28.0.3/package.xml. Probably the SDK is read-only
Exception while marshalling /usr/local/android-home/android-sdk-linux/build-tools/29.0.2/package.xml. Probably the SDK is read-only
Exception while marshalling /usr/local/android-home/android-sdk-linux/platform-tools/package.xml. Probably the SDK is read-only
Exception while marshalling /usr/local/android-home/android-sdk-linux/platforms/android-26/package.xml. Probably the SDK is read-only
Exception while marshalling /usr/local/android-home/android-sdk-linux/platforms/android-27/package.xml. Probably the SDK is read-only
Exception while marshalling /usr/local/android-home/android-sdk-linux/tools/package.xml. Probably the SDK is read-only
Checking the license for package Android SDK Build-Tools 28.0.2 in /usr/local/android-home/android-sdk-linux/licenses
Warning: License for package Android SDK Build-Tools 28.0.2 not accepted.


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':picture_library'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
     build-tools;28.0.2 Android SDK Build-Tools 28.0.2
  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/android-home/android-sdk-linux

* 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

 分析错误信息:

Failed to install the following Android SDK packages as some licences have not been accepted.
     build-tools;28.0.2 Android SDK Build-Tools 28.0.2
  To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.

得到以下结论:

构建当前的项目缺少下面的android sdk

所以下载这个sdk即可:

   build-tools;28.0.2 Android SDK Build-Tools 28.0.2

解决办法:

使用android命令 列出sdk相关的列表,以便我们选择和自己项目匹配的SDK版本 

android list sdk --all

输出如下所示:

 

 从上图可以看出,Android SDK Build-Tools 28.0.2对应的序号是7,使用android update命令安装:

android update sdk -u -a -t 7

安装完成:

 

再次在app目录下,测试gradle clean命令,就执行成功了:

 

 

 

posted @ 2019-12-06 10:10  wangju003  阅读(1569)  评论(0编辑  收藏  举报