I added the following configuration to run Travis CI on the Fahrplan Android project:
language: android
android:
components:
# All the build system components should be at the latest version
# - tools
# - platform-tools
- build-tools-21.1.1
- android-19
- sysimg-19
- add-on
- extra
# The libraries we can't get from Maven Central or similar
- extra-android-support
- extra-android-m2repository
jdk:
- oraclejdk7
- openjdk7
notifications:
email: true
before_script:
- chmod +x gradlew
- mv app/gradle.properties.example app/gradle.properties
script:
- ./gradlew clean assembleDebug
For some reason the process gets killed again and again as can be seen in the build history. It stops at different locations. The error message is not that informative:
The command "./gradlew clean assembleDebug" exited with 137
Only checking the gradle version you can force the download before you run the script (helps me to avoid error 137) but now i use wrapper so gradle-wrapper.jar is updated.
If it doesn't work, you can try to download the android dependencies before to run the script and clean before too.
I think they don't assemble by default but I like to override install stage to be sure.
In my case, error 137 is due concurrency (build/emulator) and jobs killed by Travis-ci. I solve it doing changes of this type and I don't understand it very well.
language: android
jdk:
- oraclejdk7
- openjdk7
android:
components:
# All the build system components should be at the latest version
- tools
- platform-tools
- build-tools-21.1.1
- android-19
# The libraries we can't get from Maven Central or similar
- extra-android-support
- extra-android-m2repository
notifications:
email: true
before_install:
# Disable services enabled by default
# http://docs.travis-ci.com/user/database-setup/#MySQL
- sudo /etc/init.d/mysql stop
- sudo /etc/init.d/postgresql stop
# The following did not work reliable
# - sudo service mysql stop
# - sudo service postgresql stop
install:
# Ensure Gradle wrapper is executable, download wrapper and show version
- chmod +x ./gradlew; ls -l gradlew; ./gradlew wrapper -v
# Download and show android dependencies
# - ./gradlew androidDependencies
before_script:
# Ensure signing configuration is present
- mv app/gradle.properties.example app/gradle.properties
script:
- ./gradlew clean assembleDebug
Related
Travis CI throwing the firebase_cli_path. I am not sure how can I specify this path. In Google document, it mentioned that this path will automatically detect.
Well, then I need to install the firebase tools into Travis CI, How can I do that?
This is travis.yml
dist: trusty
branches:
only:
- master
before_install:
- gem install bundler
- bundle --version
- bundle install
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
# - tools
# - platform-tools
# The BuildTools version used by your project
- build-tools-28.0.3
# The SDK version used to compile your project
- android-28
# Additional components
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
# Specify at least one system image,
# if you need to run emulator(s) during your tests
- sys-img-x86-android-26
- sys-img-armeabi-v7a-android-17
script:
- bundle exec fastlane android uatrelease
after_success:
- firebase deploy --token $FIREBASE_TOKEN --non-interactive
This is fastfile
default_platform(:android)
platform :android do
desc "Runs all the tests"
lane :test do
gradle(task: "test")
end
desc "Submit a new Beta Build to Hockey App"
lane :beta do |options|
gradle(task: "clean assembleRelease")
firebase_app_distribution(
app: "1:***********************",
testers: "abc#gmail.com",
release_notes: "Configuring Fastlane",
firebase_cli_token:ENV["FIREBASE_TOKEN"]
)
end
end
I've figured out it and it's working now. Just included the script to install the standalone firebase tool in Travis.
Check this and add this
curl -sL firebase.tools | bash
in your travis.yml file.
Sample travis.yml
dist: trusty
branches:
only:
- master
before_install:
- gem install bundler
- bundle --version
- bundle install
before_script:
- curl -sL firebase.tools | bash
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
# - tools
# - platform-tools
# The BuildTools version used by your project
- build-tools-28.0.3
# The SDK version used to compile your project
- android-28
# Additional components
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
# Specify at least one system image,
# if you need to run emulator(s) during your tests
- sys-img-x86-android-26
- sys-img-armeabi-v7a-android-17
script:
- bundle exec fastlane “your action”
Before i write this question, i already search same question about this, they did export license because still use alpha version of constrain layout. But now android already release stable version of constrain layout. I tried a lot of setup but still failed..
my latest .travis.yml
language: android
jdk: oraclejdk8
android:
components:
- platform-tools
- tools # to get the new `repository-11.xml`
- tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943)
- build-tools-25.0.0
- android-25
# Additional components
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
licenses:
- 'android-sdk-preview-license-52d11cd2'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
script:
- ./gradlew clean build
and this is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.package.my"
minSdkVersion 16
targetSdkVersion 25
versionCode 6
versionName "1.3.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-database:10.2.0'
compile 'com.google.firebase:firebase-messaging:10.2.0'
compile 'com.firebaseui:firebase-ui-database:1.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
compile 'com.android.support:design:25.0.0'
compile 'org.sufficientlysecure:html-textview:3.2'
compile 'com.android.support:recyclerview-v7:25.2.0'
}
apply plugin: 'com.google.gms.google-services'
with this setup i got this error
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> You have not accepted the license agreements of the following SDK components:
[ConstraintLayout for Android 1.0.1, Solver for ConstraintLayout 1.0.1].
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.
BUILD FAILED
Total time: 1 mins 55.975 secs
The command "./gradlew clean build" exited with 1.
Done. Your build exited with 1.
is there any solution without workaround using export license ?
Updated response
is there any solution without workaround using export license?
Yes, you can use the new sdkmanager to install the constraint library and accept the license:
- echo yes | sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2"
- echo yes | sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2"
Otherwise, the missing component will be detected by gradle and downloaded without accept it:
# Show version and download Gradle Wrapper if it's not already cached
- cd ${TRAVIS_BUILD_DIR}/${DIR} && ./gradlew --version
# Clean project and download missing dependencies and components
- cd ${TRAVIS_BUILD_DIR}/${DIR} && ./gradlew clean build
In that case, as explained below, you need to accept the license the first time via the workaround.
Full working sample using constraint-layout codelab repository for Android API level 22 to 25:
language: android
jdk: oraclejdk8
sudo: required # false for Container-Based Infrastructure, required for Sudo-enabled Infrastructure
before_cache:
- rm -f ${TRAVIS_BUILD_DIR}/gradle/caches/modules-2/modules-2.lock # Avoid to repack it due locks
- rm -f ${TRAVIS_BUILD_DIR}/gradle/caches/3.3/classAnalysis/classAnalysis.lock
- rm -f ${TRAVIS_BUILD_DIR}/gradle/caches/3.3/jarSnapshots/jarSnapshots.lock
cache:
directories:
- ${TRAVIS_BUILD_DIR}/gradle/caches/
- ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/
notifications:
email: false
android:
components: # Cookbooks version: https://github.com/travis-ci/travis-cookbooks/tree/9c6cd11
- tools # Update preinstalled tools from revision 24.0.2 to 24.4.1
- build-tools-25.0.2 # Match build-tools version used in build.gradle
- platform-tools # Update platform-tools to revision 25.0.3+
- tools # Update tools from revision 24.4.1 to 25.2.5
env:
global:
- DIR=constraint-layout-start # Project directory
- API=25 # Android API level 25 by default
- TAG=google_apis # Google APIs by default, alternatively use default
- ABI=armeabi-v7a # ARM ABI v7a by default
- QEMU_AUDIO_DRV=none # Disable emulator audio to avoid warning
- GRADLE_USER_HOME="${TRAVIS_BUILD_DIR}/gradle" # Change location for Gradle Wrapper and cache
- ANDROID_HOME=/usr/local/android-sdk-24.0.2 # Depends on the cookbooks version used in the VM
- TOOLS=${ANDROID_HOME}/tools # PATH order matters, exists more than one emulator script
- PATH=${ANDROID_HOME}:${ANDROID_HOME}/emulator:${TOOLS}:${TOOLS}/bin:${ANDROID_HOME}/platform-tools:${PATH}
- ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default)
matrix:
include: # More Emulator API levels to build in parallel
- env: API=24
- env: API=23
- env: API=22
allow_failures:
- env: API=23
- env: API=22
fast_finish: false
before_install:
- export EMULATOR="system-images;android-${API};${TAG};${ABI}" # Used to install/create emulator
- echo 'count=0' > /home/travis/.android/repositories.cfg # Avoid warning
install:
# List and delete unnecessary components to free space
- sdkmanager --list || true
- sdkmanager --uninstall "system-images;android-15;default;armeabi-v7a"
- sdkmanager --uninstall "system-images;android-16;default;armeabi-v7a"
- sdkmanager --uninstall "system-images;android-17;default;armeabi-v7a"
- sdkmanager --uninstall "system-images;android-18;default;armeabi-v7a"
- sdkmanager --uninstall "system-images;android-19;default;armeabi-v7a"
- sdkmanager --uninstall "system-images;android-21;default;armeabi-v7a"
- sdkmanager --uninstall "extras;google;google_play_services"
- sdkmanager --uninstall "extras;android;support"
- sdkmanager --uninstall "platforms;android-10"
- sdkmanager --uninstall "platforms;android-15"
- sdkmanager --uninstall "platforms;android-16"
- sdkmanager --uninstall "platforms;android-17"
- sdkmanager --uninstall "platforms;android-18"
- sdkmanager --uninstall "platforms;android-19"
- sdkmanager --uninstall "platforms;android-20"
- sdkmanager --uninstall "platforms;android-21"
- sdkmanager --uninstall "build-tools;21.1.2"
# Update sdk tools to latest version and install/update components
- echo yes | sdkmanager "tools"
- echo yes | sdkmanager "platforms;android-25" # Latest platform required by SDK tools
- echo yes | sdkmanager "platforms;android-${API}" # Android platform required by emulator
- echo yes | sdkmanager "extras;android;m2repository"
- echo yes | sdkmanager "extras;google;m2repository"
- echo yes | sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2"
- echo yes | sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2"
- echo yes | sdkmanager "$EMULATOR" # Install emulator system image
# Create and start emulator
- echo no | avdmanager create avd -n acib -k "$EMULATOR" -f --abi "$ABI" --tag "$TAG"
- emulator -avd acib -engine classic -no-window -camera-back none -camera-front none -verbose -qemu -m 512 &
# Start adbd, wait for device connected and show android serial
- adb wait-for-device get-serialno
# Show version and download Gradle Wrapper if it's not already cached
- cd ${TRAVIS_BUILD_DIR}/${DIR} && ./gradlew --version
# Clean project and download missing dependencies and components
- cd ${TRAVIS_BUILD_DIR}/${DIR} && ./gradlew clean build
# Check components status
- sdkmanager --list || true
before_script:
# Wait for emulator fully-booted and disable animations
- android-wait-for-emulator
- adb shell settings put global window_animation_scale 0 &
- adb shell settings put global transition_animation_scale 0 &
- adb shell settings put global animator_duration_scale 0 &
- sleep 30
- adb shell input keyevent 82 &
script:
# Run all device checks
- cd ${TRAVIS_BUILD_DIR}/${DIR} && ./gradlew connectedCheck
after_script:
# Show tests and lint results
- cat ${TRAVIS_BUILD_DIR}/${DIR}/*/build/outputs/androidTest-results/connected/*
- cat ${TRAVIS_BUILD_DIR}/${DIR}/*/build/reports/lint-results.xml
Two more samples using sdkmanager and avdmanager without ${DIR} workaround:
Android Maps Utils library - Google
Dexter library - Karumi
References
Official documentation related to Auto-download missing packages with Gradle
The new Emulator options are explained in Start the Emulator from the Command Line
avdmanager explained here replaces android avd since SDK tools version 25.3.0
sdkmanager explained here also enhanced to view and accept all licenses from the command line
Previous response: Since sdkmanager replaces android script
I'm a little outdated about Travis-ci and seems extra work is required now, so it's better you check:
As tir38 noticed, android tool is no longer supported. Instead, use sdkmanager...
Open issue and workarounds for this topic:
In your .travis.yml file add:
before_install:
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
Do not forgot to accept all the licences on the main android object:
android:
components:
# ...
licenses:
- android-sdk-license-.+
- '.+'
Another related issue and workaround:
If you are getting "Please install the missing components using the
SDK manager in Android Studio." error you can just install the missing
component with the sdkmanager command line tool:
echo y | sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout;1.0.0-beta4"
echo y | sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-beta"
This article explaining contraint-layout problem for Circle-ci and Travis-ci
Documentation about sdkmanager provided in the Android SDK Tools package (25.2.3+)
Outdated solution: Before android script deprecation
I don't use the default Travis-ci script to install Android components and accept licenses, from here:
# Install and update SDK
function install-and-update-sdk {
# Keep SDK packages up-to-date (only missing suggested updates are installed).
( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk -u -t \
${UPDATE_PKGS:-'platform-tools,tools,extra-android-m2repository,extra-google-m2repository'}
# Install or reinstall SDK packages (if empty, all packages are installed).
( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk -a -u -t \
${INSTALL_PKGS:-'build-tools-23.0.3,android-23'},${TARGET_PKGS:-}
}
You can accept all the licenses at the same time if you do it like this:
# THE SETUP STAGE
# ---------------
# If you comment out this section, Travis CI will install for you the components you define here.
# Check your project requirements and the components included by default on Travis-ci VM images.
# Check required: https://github.com/google/iosched/blob/master/doc/BUILDING.md
# Check defaults: http://docs.travis-ci.com/user/languages/android/#Pre-installed-components
android:
components:
# Check Android SDK tools: http://developer.android.com/tools/sdk/tools-notes.html
# Check Android SDK Platform-tools: http://developer.android.com/tools/revisions/platforms.html
# Comment the lines below if the latest revisions of Android SDK Tools are included by default.
# - tools
# - platform-tools
# ...
licenses:
# Check licenses: http://docs.travis-ci.com/user/languages/android/#Dealing-with-Licenses
# By default Travis will accept all the licenses, but it's also possible to define a white list:
# White list current android-sdk-license revision.
# - 'android-sdk-license-5be876d5'
# White list all android-sdk-license revisions.
# - 'android-sdk-license-.+'
# White list all the licenses.
- '.+'
The simplest solution that worked for me was to copy the SDK licenses to my project from SDK and then tell Travis to copy them to itself while building.
There's already a closed issue for this on Travis's Github page and one of the mentioned solutions on it is definitely working currently.
Solution
Copy the licenses folder found in Android SDK's root directory.
Paste it in the root directory of your own project on the same hierarchy where .travis.yml file is.
Add these commands to your .travis.yml's before_install block:
.travis.yml:
before_install:
- mkdir "$ANDROID_HOME/licenses" || true
- cp ./licenses/* "$ANDROID_HOME/licenses/"
Exact link to solution: https://github.com/travis-ci/travis-ci/issues/6617#issuecomment-369580270
I had the same issue and the problem was that I was using one old version of android build tools and gradle version, just updating them to the last version available did the trick.
For example, today the last version of gradle is 3.3, and build tools last version is 2.3.3.
My build.gradle file looks like that
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
This was raised as an issue some time ago https://issuetracker.google.com/issues/37102998
and if you go to last answers you will se that the issue was fixed by just upgrading gradle version and build tools version.
I found out that each time Travis CI build the project, it has to download again all the SDK packages like the platform-tools, the support library, the current SDK, etc.
Is it possible to avoid it and make Travis reuse what it downloaded the first time ?
I probably made some mistakes in my .travis.yml file, here is a copy of it
language: android
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
- platform-tools
- tools
# The BuildTools version used by your project
- build-tools-23.0.2
# The SDK version used to compile your project
- android-23
# Additional components
- extra-android-support
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- addon-google_apis-google-19
# Specify at least one system image,
# if you need to run emulator(s) during your tests
# - sys-img-armeabi-v7a-android-19
# - sys-img-x86-android-17
script:
- ./gradlew check
- ./gradlew test --continue
# - ./gradlew build connectedCheck
Why do Travis CI download everything each time it builds?
We talk about this here, Travis-ci downloads the cache from S3, so there is not a significant speed improvement caching big files like Android SDK.
How to include Android SDK in Travis-ci cache? (not recommended)
The relevant bits are here, you can add to the cache any file you like and know his path:
cache:
directories:
- ${TRAVIS_BUILD_DIR}/gradle/caches/
- ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/
- ${TRAVIS_BUILD_DIR}/android-sdk/extras/ # please don't include sys-images
I did it time ago, you can see the code in the link shared by #nicolas-f:
language: android
jdk: oraclejdk8
env:
global:
- GRADLE_USER_HOME=${TRAVIS_BUILD_DIR}/gradle
- ANDROID_HOME=${TRAVIS_BUILD_DIR}/android-sdk
- SDK=${TRAVIS_BUILD_DIR}/android-sdk
- PATH=${GRADLE_USER_HOME}/bin/:${SDK}/:${SDK}/tools/:${SDK}/platform-tools/:${PATH}
before_install:
- export OLD_SDK=/usr/local/android-sdk-24.0.2;
mkdir -p ${SDK};
cp -u -R ${OLD_SDK}/platforms ${SDK}/platforms;
cp -u -R ${OLD_SDK}/system-images ${SDK}/system-images;
cp -u -R ${OLD_SDK}/tools ${SDK}/tools
cache:
apt: true
directories:
- ${TRAVIS_BUILD_DIR}/gradle/caches/
- ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/
- ${TRAVIS_BUILD_DIR}/android-sdk/extras/
android:
components:
# Update Android SDK Tools
- tools
- platform-tools
- build-tools-23.0.2
- android-23
- add-on
- extra
script:
- ./gradlew check
Use ls to confirm that the SDK path has not changed another time.
It's not currently necessary to move the SDK, and you need to update other things, perhaps add another tools after platform-tools, this code is outdated.
I am trying to set up Travis for Android. Running the build seems to work so far, but when it comes to the tests, it complains about "No connected devices!"
:app:connectedAndroidTestDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:connectedAndroidTestDebug'.
> com.android.builder.testing.api.DeviceException: java.lang.RuntimeException:
No connected devices!
Here is my .travis.yml, and from what I understand, I am creating and starting an emulator for the tests, just the way as the documentation says.
language: android
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
# - platform-tools
# - tools
# The BuildTools version used by your project
- build-tools-22.0.1
# The SDK version used to compile your project
- android-22
# Additional components
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
# - addon-google_apis-google-19
# - add-on
# - extra
# Specify at least one system image,
# if you need to run emulator(s) during your tests
- sys-img-armeabi-v7a-android-22
# - sys-img-x86-android-17
licenses:
- 'android-sdk-license-.+'
# Emulator Management: Create, Start and Wait
before_script:
- echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
Can you tell me what I'm doing wrong and how to fix it?
Unfortunately i am not allowed to comment, as i just want to complete DominicJodoin's answer. Correct indentation and a longer ADB_INSTALL_TIMEOUT is necessary as DominicJodoin already stated.
In my opinion your Emulator is running but not ready to install an apk. With - adb wait-for-device you wait until the device connected. According to the Documentation this means:
Note that this command does not cause adb to wait until the entire system is fully booted. For that reason, you should not prepend it to other commands that require a fully booted system.
Try replacing this line with - android-wait-for-emulator in your travis.yml instead.
Travis.yml
language: android
jdk: oraclejdk7
cache:
directories:
- node_modules
sudo: false
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
# - platform-tools
# - tools
# The BuildTools version used by your project
- build-tools-22.0.1
# The SDK version used to compile your project
- android-22
# Additional components
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
# - addon-google_apis-google-19
# - add-on
# - extra
# Specify at least one system image,
# if you need to run emulator(s) during your tests
- sys-img-armeabi-v7a-android-21
# - sys-img-x86-android-17
licenses:
- 'android-sdk-license-.+'
env:
global:
# install timeout in minutes (2 minutes by default)
- ADB_INSTALL_TIMEOUT=8
# Emulator Management: Create, Start and Wait
before_script:
- echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
script:
- android list target
- ./gradlew connectedAndroidTest
I think your problem is the sys-img-armeabi-v7a-android-22 image is not available yet on Travis CI.
Indeed if you run the following command on Travis CI: android list target, the output for android-22 shows no Tag/ABIs : no ABIs.
I would suggest you try running your tests on the sys-img-armeabi-v7a-android-21 in the meantime.
You can have a look at a sample Android project with unit tests I forked and ran successfully with your components but with sys-img-armeabi-v7a-android-21 image on Travis CI:
Sample project
Travis CI build log
Hope this helps!
Edit: android-22 image should be available shortly on Travis CI. See the following pull request.
I wanted to use a more recent emulator. Unfortunately I wasn't able to make it work on android-26 or 27, but I was able to make it work on android-25. The ABI names were changed. Here's what works for me:
language: android
jdk:
- oraclejdk8
env:
global:
- ANDROID_BUILD_TOOLS_VERSION=26.0.2
- ANDROID_ABI=arm64-v8a
- ANDROID_TAG=google_apis
- ANDROID_API_LEVEL=26
- EMULATOR_API_LEVEL=25
- ADB_INSTALL_TIMEOUT=8 # minutes (2 minutes by default)
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
- tools
- platform-tools
- tools
# The BuildTools version used by your project
- build-tools-$ANDROID_BUILD_TOOLS_VERSION
# The SDK version used to compile your project
- android-$ANDROID_API_LEVEL
- android-$EMULATOR_API_LEVEL
# Support library
# Latest artifacts in local repository
- extra-android-m2repository
# Specify at least one system image,
# if you need to run emulator(s) during your tests
- sys-img-$ANDROID_ABI-$ANDROID_TAG-$EMULATOR_API_LEVEL
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/
# Emulator Management: Create, Start and Wait
before_script:
- android list targets
- echo no | android create avd --force -n test -t "android-"$EMULATOR_API_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG
- emulator -list-avds
- emulator -avd test -no-window &
- android-wait-for-emulator
- adb devices
- adb shell input keyevent 82 &
I found the key ADB_TIMEOUT_INSTALL bit in J-Bossi answer, and it starts the emulator in before_script like Travis-CI is currently recommending, but I had issues with the VM running out of memory. So instead of running the emulator while the build is running, I changed my config to run the build, then start the emulator, then run the tests.
sudo: false
language: android
env:
global:
# switch glibc to a memory conserving mode
- MALLOC_ARENA_MAX=2
# wait up to 10 minutes for adb to connect to emulator
- ADB_INSTALL_TIMEOUT=10
android:
components:
- platform-tools
- extra-android-m2repository
- build-tools-22.0.1
- android-22
- sys-img-armeabi-v7a-android-22
script:
- ./gradlew assemble lint
after_script:
# Emulator Management: Create, Start and Wait
- echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
# now run the tests
- ./gradlew connectedCheck
I have got a strange error and cannot find a solution:
* What went wrong:
Execution failed for task ':app:compileDebugAndroidTestGroovy'.
> Unable to load class de.rheinfabrik.mvvm_example.activities.DetailsActivity due to missing dependency android/support/v4/view/LayoutInflaterFactory
But it´s impossible. This project works locally. Also the dependency is there.
Here my .travis.yml
language: android
jdk: oraclejdk8
env:
matrix:
- ANDROID_TARGET=android-22 ANDROID_ABI=armeabi-v7a
global:
- TERM=dumb
android:
components:
- build-tools-21.1.2
- android-22
- sys-img-armeabi-v7a-android-22
- extra
# Emulator Management: Create, Start and Wait
before_script:
- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
script: cd MVVM-Example && ./gradlew app:connectAndroidTest --stacktrace -PdisablePreDex
Anyone have an idea why the dependency LayoutInflaterFactory is missing?
https://travis-ci.org/AHarazim/android-mvvm-example
Try
- build-tools-22.0.1
http://developer.android.com/tools/revisions/build-tools.html
Build Tools, Revision 22.0.0 (March 2015) Added support for Android
5.1 (API level 22).
And I think that is connectedAndroidTest.
Update, try to get latest tools versions, Travis-ci reverted the last VM update, good luck, if this doesn't work, I don't know another possible reason:
language: android
android:
components:
- platform-tool
- tool
- android-22
- build-tools-22.0.1
- extra-android-m2repository
- extra-google-m2repository
- sys-img-armeabi-v7a-android-22
Update2: I forked your project, tried my suggestions and it didn't work. But I followed a discussion about to add
retrolambda {
jvmArgs '-noverify'
}
As you already did. And there was this variant, I didn't read it and rushed to the solution and works :)
script:
- cd MVVM-Example
- ./gradlew prepareDebugDependencies
- ./gradlew assembleDebug # you can run clean before assemble
- ./gradlew app:connectedAndroidTest --info
I'm not familiar with this retrolambda stuff, please explain the solution for other if it works for you, I thought that it was a simple travis issue.