我正在尝试在docker中运行gitlab runner上的功能测试,就像描述here一样。但是命令android
已弃用,现在我们必须使用sdkmanager
。这是我的.yml
:
image: openjdk:8-jdk
variables:
ANDROID_COMPILE_SDK: "26"
ANDROID_BUILD_TOOLS: "26.0.2"
ANDROID_SDK_TOOLS: "24.4.1"
before_script:
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
- wget --quiet --output-document=sdk-tools-linux-3859397.zip https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
- unzip sdk-tools-linux-3859397.zip
- yes | tools/bin/sdkmanager --verbose "build-tools;${ANDROID_BUILD_TOOLS}"
- yes | tools/bin/sdkmanager "emulator"
- yes | tools/bin/sdkmanager "extras;google;m2repository"
- yes | tools/bin/sdkmanager "extras;google;google_play_services"
- yes | tools/bin/sdkmanager "platform-tools"
- yes | tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}"
- yes | tools/bin/sdkmanager "sources;android-${ANDROID_COMPILE_SDK}"
- yes | tools/bin/sdkmanager --licenses
- export ANDROID_HOME=$PWD/tools
- export ANDROID_SDK_ROOT=$PWD/tools
- export PATH=$PATH:$PWD/tools/platform-tools/
- export GRADLE_USER_HOME=$/.gradle
- chmod +x ./gradlew
如果我运行它,我会在日志中看到:
$ yes | tools/bin/sdkmanager --verbose "build-tools;${ANDROID_BUILD_TOOLS}"
Info: Parsing legacy package: /builds/git/proj/android-app/tools
Info: Parsing /builds/git/proj/android-app/tools/package.xml
Warning: File /root/.android/repositories.cfg could not be loaded.
License android-sdk-license:
---------------------------------------
Terms and Conditions
...//Whole license
Accept? (y/N): Info: Preparing "Install Android SDK Build-Tools 26.0.2 (revision: 26.0.2)".
Info: "Install Android SDK Build-Tools 26.0.2 (revision: 26.0.2)" ready.
Info: Finishing "Install Android SDK Build-Tools 26.0.2 (revision: 26.0.2)"
Info: Installing Android SDK Build-Tools 26.0.2 in /builds/git/proj/android-app/build-tools/26.0.2
Info: "Install Android SDK Build-Tools 26.0.2 (revision: 26.0.2)" complete.
Info: "Install Android SDK Build-Tools 26.0.2 (revision: 26.0.2)" finished.
done
ERROR: Job failed: exit code 1
没有解释的错误。如果我尝试使用echo y | ...
而不是yes | ...
设置安装命令,则安装完全正常,但稍后我会收到错误,即不接受许可证。然后我插入命令:
- yes | tools/bin/sdkmanager --licenses
它在没有解释的情况下给出了同样的错误:
Accept? (y/N): All SDK package licenses accepted
done
ERROR: Job failed: exit code 1
我不知道为什么它以错误告终,并且没有解释发生了什么。
编辑:经过多次尝试,我得出结论,包含- yes | ...
的每个命令都会返回无法解释的错误。如果我设置- echo y | ...
而不是- yes | ...
,那么我在构建app时会得到:
A problem occurred configuring project ':app'.
> You have not accepted the license agreements of the following SDK components:
[Android SDK Platform 26, 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.
BUILD FAILED in 45s
ERROR: Job failed: exit code 1
答案 0 :(得分:-1)
这看起来像码头图像问题。
简单的解决方法:
- yes | tools/bin/sdkmanager --licenses || true