This reply covers up to Travis automatic testing. See the Medium article for the complete version: automatic testing and deployment.
Travis CI (@ API 26+)
Apparently from API 24 setting up the emulator is a pain on Travis is a pain[1][2][3][4].
Sean Barbeau, who's been digging through this for a lot more time than I have, has pretty much considered it impossible to emulate.
But there is a working and simpler alternative for API 26+, which is running the tests with gradlew
instead of the adb emulator
. It seems to have some limitations, but it should work. Credits to PocketHub.
sudo: required
language: android
jdk: oraclejdk8
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -rf $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.android/build-cache
env:
global:
- ANDROID_API=26
- ANDROID_BUILD_TOOLS=26.0.2
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
- android-${ANDROID_API}
- build-tools-${ANDROID_BUILD_TOOLS}
- extra
script:
- ./gradlew clean test build
Environment variables that you might have to adapt to your project ones:
Some information should be available either in the build.gradle
or AndroidStudio -> Settings -> Android SDK -> SDK Tools
(if you're building a new project with an updated AndroidStudio you should just pick the latest versions in the following links)
ANDROID_API: https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels
ANDROID_BUILD_TOOLS: https://developer.android.com/studio/releases/build-tools.html
Example .travis.yml setup (with autodeploy to GitHub releases).