When I push to remote Travis CI starts a build, but it does never finish because licences are not accepted. I get to Accept? (y/N): line in the Travis build and it waits until timeout.
Travis file:
sudo: required
language: android
jdk: oraclejdk8
dist: trusty
android:
components:
- tools
- tools
- platform-tools
- build-tools-28.0.3
- android-28
- add-on
- extra
before_install:
- echo yes | sdkmanager "build-tools;28.0.3"
- echo yes | sdkmanager "platforms;android-28"
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\ " > "$ANDROID_HOME/licenses/android-sdk-preview-license"
- sdkmanager "system-images;android-28;google_apis;x86"
- echo no | avdmanager create avd --force -n emulatorApi28 -k "system-images;android-28;google_apis;x86"
- emulator -avd test -no-audio -no-window &
- ./gradlew dependencies || true
before_script:
- android-wait-for-emulator
- adb shell input keyevent 82 &
script:
- ./gradlew build connectedCheck
- "./gradlew clean build connectedCheck -PdisablePreDex --stacktrace"
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.android/build-cache
Any suggestions on why it never accepts licenses?
Just add - yes | sdkmanager --licenses >/dev/null to your before_install stage.
Related
I'm trying to run android instrumented tests on Gitlab CI on a remote linux machine, everything works fine until it runs the gradle task for the tests, it fail without any further information.
I should also mention that one out of ten times, it works.
Can you spot something wrong?
Here is my gitlab CI file:
variables:
ANDROID_COMPILE_SDK: "30"
ANDROID_BUILD_TOOLS: "30.0.3"
ANDROID_SDK_TOOLS: "6858069"
ANDROID_APK_FOLDER: "app/build/outputs/apk"
EMULATOR_VERSION: "24"
ENVIRONMENT: Staging
before_script:
- export ANDROID_HOME=$PWD/android-sdk
- export ANDROID_SDK_ROOT=${ANDROID_HOME}
- export ANDROID_TOOLS_PATH=${ANDROID_HOME}/platform-tools
- export ANDROID_SDK_MANAGER=${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager
- export ANDROID_AVD_MANAGER=${ANDROID_HOME}/cmdline-tools/latest/bin/avdmanager
- export ANDROID_EMULATOR_HOME=${ANDROID_HOME}/emulator
- export ANDROID_EMULATOR_PATH=${ANDROID_HOME}/avd
- export PATH="$PATH:${ANDROID_TOOLS_PATH}"
- export ADB_INSTALL_TIMEOUT=10
# Update system
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 tree libx11-dev libpulse0 libgl1 libnss3 libxcomposite-dev libxcursor1 libasound2
# Download Android SDK
- wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip
- mkdir ${ANDROID_HOME}
- unzip -d ${ANDROID_HOME}/cmdline-tools android-sdk.zip
- echo y | rm android-sdk.zip
- mv ${ANDROID_HOME}/cmdline-tools/cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest
# Install Android Build Tools
- echo y | ${ANDROID_SDK_MANAGER} --sdk_root=${ANDROID_HOME} --licenses
- echo y | ${ANDROID_SDK_MANAGER} --sdk_root=${ANDROID_HOME} --update > update.log
- echo y | ${ANDROID_SDK_MANAGER} --sdk_root=${ANDROID_HOME} "platforms;android-${ANDROID_COMPILE_SDK}" "build-tools;${ANDROID_BUILD_TOOLS}" "extras;google;m2repository" "extras;android;m2repository" > installPlatform.log
# Create untracked files
- echo -e "android.useAndroidX=true\nandroid.enableJetifier=true" > gradle.properties
- echo ${RELEASE_KEYSTORE} | base64 -d > app/upload.jks
stages:
- setup
- e2e_test
setup:
stage: setup
script:
- chmod +x ./gradlew
- ./gradlew clean
############################################## TESTS ###############################################
e2e_test:
stage: e2e_test
only:
- develop
- tags
script:
- wget --quiet --output-document=android-wait-for-emulator.sh https://raw.githubusercontent.com/travis-ci/travis-cookbooks/0f497eb71291b52a703143c5cd63a217c8766dc9/community-cookbooks/android-sdk/files/default/android-wait-for-emulator
- chmod +x android-wait-for-emulator.sh
- echo y | ${ANDROID_SDK_MANAGER} --update > update.log
- echo y | ${ANDROID_SDK_MANAGER} "platform-tools" "emulator" "system-images;android-${EMULATOR_VERSION};default;armeabi-v7a" > installEmulator.log
- echo no | ${ANDROID_AVD_MANAGER} --verbose create avd -n test --force -k "system-images;android-${EMULATOR_VERSION};default;armeabi-v7a"
- ${ANDROID_EMULATOR_HOME}/emulator -avd test -no-snapshot-save -no-audio -no-window -debug -verbose &
- ./android-wait-for-emulator.sh
- adb shell input keyevent 82
- ./gradlew connected${ENVIRONMENT^}DebugAndroidTest --stacktrace --continue || true
- adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done
And here is the error I get :
> Task :app:connectedStagingDebugAndroidTest
Unable to install /builds/onl-dev-team/retail_checkout_app/app/build/outputs/apk/staging/debug/app-staging-2.2.1.apk
com.android.ddmlib.InstallException
at com.android.ddmlib.internal.DeviceImpl.installRemotePackage(DeviceImpl.java:1316)
at com.android.ddmlib.internal.DeviceImpl.installPackage(DeviceImpl.java:1136)
com.android.build.gradle.internal.testing.ConnectedDevice > runTests[test(AVD) - 7.0] FAILED
com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException
at com.android.build.gradle.internal.testing.ConnectedDevice.installPackage(ConnectedDevice.java:133)
at com.android.ddmlib.internal.DeviceImpl.installPackage(DeviceImpl.java:1112)
at com.android.ddmlib.internal.DeviceImpl.installPackage(DeviceImpl.java:1101)
at com.android.build.gradle.internal.testing.ConnectedDevice.installPackage(ConnectedDevice.java:127)
at com.android.build.gradle.internal.testing.SimpleTestRunnable.run(SimpleTestRunnable.java:135)
at com.android.build.gradle.internal.tasks.Workers$ProfileAwareExecutorServiceAdapter$submit$submission$1.run(Workers.kt:165)
at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: com.android.ddmlib.ShellCommandUnresponsiveException
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:691)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:470)
at com.android.ddmlib.internal.DeviceImpl.executeShellCommand(DeviceImpl.java:727)
at com.android.ddmlib.internal.DeviceImpl.installRemotePackage(DeviceImpl.java:1307)
... 12 more
[no message defined]
As explained in this post https://githubmemory.com/repo/mingchen/docker-android-build-box/issues/58,
at the startup, the android system undergoes a lot of processes and may be busy when trying to install the apk. This would cause for example a ShellCommandUnresponsiveException.
To solve this I just added as recommended a sleep 180 after the line with adb shell input keyevent 82
My build fails in Travis CI. It does not accept Android SDK License:
$ sdkmanager "system-images;android-28;google_apis;x86"
Warning: File /home/travis/.android/repositories.cfg could not be loaded.
License android-sdk-license:
---------------------------------------
Terms and Conditions
.
.
. //bunch of terms here
.
.
Accept? (y/N):
My Travis yml file:
sudo: required
language: android
jdk: oraclejdk8
android:
components:
- tools
- tools
- platform-tools
- build-tools-28.0.3
- android-28
- add-on
- extra
before_install:
- echo yes | sdkmanager "build-tools;28.0.3"
- echo yes | sdkmanager "platforms;android-28"
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
- sdkmanager "system-images;android-28;google_apis;x86"
- echo no | avdmanager create avd --force -n emulatorApi28 -k "system-images;android-28;google_apis;x86"
- emulator -avd test -no-audio -no-window &
- ./gradlew dependencies || true
before_script:
- android-wait-for-emulator
- adb shell input keyevent 82 &
script:
- ./gradlew build connectedCheck
- "./gradlew clean build connectedCheck -PdisablePreDex --stacktrace"
before_cache:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.android/build-cache
cache:
directories:
-$HOME/.gradle/caches/
-$HOME/.gradle/wrapper/s
licenses:
- 'android-sdk-preview-license-.+'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
Any suggestions?
EDIT:
sudo: required
language: android
jdk: oraclejdk8
android:
licenses:
- 'android-sdk-preview-license-.+'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
components:
- tools
- tools
- platform-tools
- build-tools-28.0.3
- android-28
- add-on
- extra
before_install:
- echo y | sdkmanager "build-tools;28.0.3"
- echo y | sdkmanager "platforms;android-28"
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\ " > "$ANDROID_HOME/licenses/android-sdk-preview-license"
- sdkmanager "system-images;android-28;google_apis;x86"
- echo no | avdmanager create avd --force -n emulatorApi28 -k "system-images;android-28;google_apis;x86"
- emulator -avd test -no-audio -no-window &
- ./gradlew dependencies || true
before_script:
- android-wait-for-emulator
- adb shell input keyevent 82 &
script:
- ./gradlew build connectedCheck
- "./gradlew clean build connectedCheck -PdisablePreDex --stacktrace"
before_cache:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.android/build-cache
cache:
directories:
-$HOME/.gradle/caches/
-$HOME/.gradle/wrapper/sis?
Take a look at the documentation, the licenses part should be under the android part. So it should be like this:
android:
components:
...
licenses:
- 'android-sdk-preview-license-.+'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
I use Gitlab CI for continuous integration. After every commit I have 3 jobs in the pipeline: debug, unitTests and instrumentedTests. But now instrumented tests failed because of the timeout. I added my gitlab-ci.yml file below
I've already tried downgrade android sdk versions, but no luck at all. Maybe there are some commands for yml-file that could fix the problem.
Also maybe somebody knows how to make all tests not failed for EMULATOR_VERSION > 22. 24 or higher never worked at all.
image: openjdk:8-jdk
variables:
ANDROID_COMPILE_SDK: "28"
ANDROID_BUILD_TOOLS: "28.0.3"
ANDROID_SDK_TOOLS: "4333796" # from https://developer.android.com/studio/#command-tools
EMULATOR_VERSION: "22"
before_script:
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
- wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_TOOLS}.zip
- unzip -d android-sdk-linux android-sdk.zip
- echo y | android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
- echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" >/dev/null
- echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
- export ANDROID_HOME=$PWD/android-sdk-linux
- export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
- chmod +x ./gradlew
# temporarily disable checking for EPIPE error and use yes to accept all licenses
- set +o pipefail
- yes | android-sdk-linux/tools/bin/sdkmanager --licenses
- set -o pipefail
stages:
- build
- test
assembleDebug:
stage: build
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/
unitTests:
stage: test
script:
- ./gradlew test
instrumentedTests:
stage: test
script:
- wget --quiet --output-document=android-wait-for-emulator https://raw.githubusercontent.com/travis-ci/travis-cookbooks/0f497eb71291b52a703143c5cd63a217c8766dc9/community-cookbooks/android-sdk/files/default/android-wait-for-emulator
- chmod +x android-wait-for-emulator
- android-sdk-linux/tools/bin/sdkmanager --update > update.log
- android-sdk-linux/tools/bin/sdkmanager "platform-tools" "emulator" "system-images;android-${EMULATOR_VERSION};default;armeabi-v7a" > installEmulator.log
- echo no | android-sdk-linux/tools/bin/avdmanager create avd -n test -k "system-images;android-${EMULATOR_VERSION};default;armeabi-v7a"
- android-sdk-linux/emulator/emulator -avd test -no-window -no-audio &
- ./android-wait-for-emulator
- adb shell input keyevent 82
- ./gradlew connectedCheck
There are following factors:
looks like google dropped support of qemu engine and only ranchu is supported for now
sdk was partially updated but there are bugs in update process
While qemu is no more supported this concrete bug with hanging seems wouldn't fixed ever.
For switch to ranchu environment:
avoid using *default* platform for avd's, prefer *google-api*'s one (while ranchu kernel is missed in default platforms)
update sdk with --channel=4
Just in case it helped me.
My Travis build keeps failing because apparently it does not recognize the arm abi. Here's my full .travis.yml:
language: android
sudo: required
env:
global:
- ANDROID_API_LEVEL=28
- ANDROID_BUILD_TOOLS_VERSION=28.0.3
- ANDROID_ABI=armeabi-v7a
- ANDROID_EMU_API_LEVEL=27
android:
components:
- tools
- platform-tools
- tools # appears twice as per Travis docs
- build-tools-$ANDROID_BUILD_TOOLS_VERSION
- android-$ANDROID_API_LEVEL
- android-$ANDROID_EMU_API_LEVEL
- extra-android-m2repository
- sys-img-${ANDROID_ABI}-android-${ANDROID_EMU_API_LEVEL}
licenses:
- 'android-sdk-preview-license-52d11cd2'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.android/build-cache
before_script:
- echo no | android create avd --force -n test -t android-$ANDROID_EMU_API_LEVEL --abi $ANDROID_ABI -c 100M
- emulator -avd test -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
- chmod +x gradlew
script:
- android list target
- ./gradlew clean build
- ./gradlew test
- ./gradlew connectedCheck
I have also tried to change the abi in the emulator to google_apis/armeabi-v7a to no avail. Also tried to add google_apis in the system image download. I have currently tried API_LEVEL 22, 27 and 28.
What is the issue here?
You can try ANDROID_ABI=arm64-v8ainstead of ANDROID_ABI=armeabi-v7a
I don't know if this is still relevant since it was asked 4 months ago, but I also just recently had this same issue. I tried many different things people suggested and none of it worked till I set it up this way:
language: android
sudo: required
jdk: oraclejdk8
env:
global:
- ANDROID_API_LEVEL=28
- ANDROID_BUILD_TOOLS_VERSION=28.0.3
- ANDROID_ABI=armeabi-v7a
android:
components:
- tools
- platform-tools
- tools
- extra-android-m2repository
licenses:
- 'android-sdk-preview-license-52d11cd2'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
before_install:
- touch $HOME/.android/repositories.cfg
- yes | sdkmanager "platforms;android-28"
- yes | sdkmanager "build-tools;28.0.3"
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.android/build-cache
before_script:
- chmod +x gradlew
script:
- ./gradlew clean build
- ./gradlew test
We are trying to integrate our android app with travis CI. But it always fails with cannot access ‘gradlew’: No such file or directory. We can run the gradlew script from our local computer and the file is tracked by git. What can the problem be?
Our .travis.yml file:
sudo: false
language: android
jdk: oraclejdk8
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.android/build-cache
before_script:
- cd TreasurePleasure
- echo no | android create avd --force -n test -t "android-"$ANDROID_EMULATOR_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG
- emulator -avd test -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
android:
components:
- tools
- tools # Running this twice get's the latest build tools (https://github.com/codepath/android_guides/wiki/Setting-up-Travis-CI)
- platform-tools
- build-tools-27.0.3
- android-27
- android-$ANDROID_EMULATOR_LEVEL
- sys-img-armeabi-v7a-google_apis-$ANDROID_EMULATOR_LEVEL
licenses:
- '.+'
env:
global:
- ANDROID_API_LEVEL=27
- ANDROID_EMULATOR_LEVEL=21
- ANDROID_BUILD_TOOLS_VERSION=27.0.3
- ANDROID_ABI=armeabi-v7a
- ANDROID_TAG=google_apis
- ADB_INSTALL_TIMEOUT=20
before_install:
- chmod +x gradlew
- yes | sdkmanager "platforms;android-27"
script:
- "./gradlew clean build connectedCheck -PdisablePreDex --stacktrace"
# run tests against the emulator
- ./gradlew connectedAndroidTest
# run tests against the JVM
- ./gradlew test
Most of this is copy paste since this is the first project for us that are using Travis CI.
Our error:
This is how it works in my scripts:
before_script:
- cd ${TRAVIS_BUILD_DIR}/TreasurePleasure
- chmod +x ./gradlew
script: "./gradlew assemble"