1 未自动授权时现象
未授权的Dockerfile脚本片段:
# update sdkmanager and install build tools
ENV ANDROID_VERSION=25 \
ANDROID_BUILD_TOOLS_VERSION=26.0.2
RUN $ANDROID_HOME/tools/bin/sdkmanager --update
RUN $ANDROID_HOME/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" \
"platforms;android-${ANDROID_VERSION}" \
"platform-tools"
执行到上面脚本会出现如下提示:
Failed to install the following Android SDK packages as some licences have not been accepted.
platforms;android-25 Android SDK Platform 25
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: /opt/android-sdk-linux
2 自动授权
自动授权接受license的Dockerfile写法如下,即在sdkmanager指令前添加yes |
,则脚本执行到该位置会自动接受,如下图。
# update sdkmanager and install build tools
ENV ANDROID_VERSION=25 \
ANDROID_BUILD_TOOLS_VERSION=26.0.2
RUN yes | $ANDROID_HOME/tools/bin/sdkmanager --update
RUN yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses && yes | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" \
"platforms;android-${ANDROID_VERSION}" \
"platform-tools"