Android Jenkins 打包时提示没同意 license 导致无法编译

[TOC]

ConstraintLayout 1.0.2 授权问题

表现

* What went wrong:
A problem occurred configuring project ':test'.
> You have not accepted the license agreements of the following SDK components:
  [ConstraintLayout for Android 1.0.2, Solver for ConstraintLayout 1.0.2].
  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.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

解决方法

直接写入授权

mkdir -p "$ANDROID_HOME/licenses"
echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"

如果是 Jenkins 构建里面的

配置好 ANDROID_HOME 环境变量,然后执行

(while :; do echo 'y'; sleep 3; done) | $ANDROID_HOME/tools/android update sdk -u

下载 build tools

https://dl.google.com/android/repository/tools_r25.2.3-linux.zip
https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip
https://dl.google.com/android/repository/tools_r25.2.3-windows.zip
下载你自己平台的

安装授权

解压后到tools/bin文件夹下 执行

./sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2"

Android SDK Build-Tools 26.0.2 授权问题

表现

> You have not accepted the license agreements of the following SDK components:
  [Android SDK Build-Tools 26.0.2].
  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.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

解决方法

echo y | android update sdk --no-ui --all --filter build-tools-26.0.2,extra-android-m2repository

你可能感兴趣的:(Android Jenkins 打包时提示没同意 license 导致无法编译)