我试图在Android回购中使用Travis CI,这让我很头疼。
这是我的.travis.yml文件
sudo: required
jdk: oraclejdk8
language: android
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
- tools
- build-tools-26.0.2
- platform-tools
- tools
# The SDK version used to compile your project
- android-25
# Additional components
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- extra-android-support
- addon-google_apis-google-25
# Specify at least one system image,
# if you need to run emulator(s) during your tests
- sys-img-armeabi-v7a-android-25
env:
global:
- 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
#- ANDROID_HOME=/usr/local/android-sdk-26.1.1 # 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)
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
- cd ./GimnasIO
- chmod +x gradlew
install:
- 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 -verbose -qemu -m 512 &
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 &
- adb shell input keyevent 82 &
script:
- ./gradlew build connectedCheck
after_script:
- cat ${TRAVIS_BUILD_DIR}/*/build/outputs/androidTest-results/connected/*
我对ANDROID_HOME行进行了评论,因为它给了我一个错误,并且显然无法正常工作。
所以,我查找了问题并发现添加" android-wait-for-emulator"应该工作正常,但它没有。这是第一个错误:
Unable to install /home/travis/build/.../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?)
知道为什么会一直这样吗?