I am trying to use travis CI for one of my projects but I am unable to get it working. I managed to make a .travis.yml config file and builds were passing. But surprisingly builds started failing again when I pushed a commit after a couple of hours. Also, builds failed when i restarted a build which was previously passing. I don't understand why is this happening randomly.
Here is the travis log: Travis Log
and the .travis.yml file looks like this:
language: android
jdk: oraclejdk8
sudo: required
env:
matrix:
- ANDROID_TARGET=android-21 ANDROID_ABI=armeabi-v7a
android:
components:
- tools
- platform-tools
- tools
- build-tools-26.0.2
- $ANDROID_TARGET
- android-26
- sys-img-armeabi-v7a-$ANDROID_TARGET
licenses:
- android-sdk-preview-license-.+
- android-sdk-license-.+
- google-gdk-license-.+
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"
- chmod +x gradlew
- ./gradlew dependencies || true
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:
# Create and start emulator
- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
- emulator -avd test -no-skin -no-audio -no-window &
- adb wait-for-device
- adb shell input keyevent 82 &
script: ./gradlew connectedAndroidTest
And the gradle file relevant snippet:
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.amit.realmmvp"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
There are similar questions on stack overflow about the same issue but they all relate to android studio and emulator not getting started. But, in travis config file ,I'm already asking it to wait until emulator comes online using - adb wait-for-device
Can anyone please help me figure this out? Thanks.
EDIT
The build process fails here:
:app:connectedDebugAndroidTestUnable to install /home/travis/build/AmitBarjatya/RealmMvp/app/build/outputs/apk/debug/app-debug.apk
com.android.ddmlib.InstallException: Unknown failure (Error: Could not access the Package Manager. Is the system running?)
at com.android.ddmlib.Device.installRemotePackage(Device.java:1004)
at com.android.ddmlib.Device.installPackage(Device.java:911)
at com.android.builder.testing.ConnectedDevice.installPackage(ConnectedDevice.java:122)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:126)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:52)
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)