我发现了几个Travis CI的问题,但其中一个我无法解决。
我一直遇到一个常见的错误:
com.android.ddmlib.InstallException: Failed to establish session
这是我的travis文件:
language: android
before_install:
- chmod +x gradlew
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
- tools
- build-tools-23.0.3
# Additional components
- extra-google-m2repository
- extra-android-m2repository
# The SDK version used to compile your project
- android-23
# Specify at least one system image,
# if you need to run emulator(s) during your tests
- sys-img-armeabi-v7a-android-23
#- sys-img-x86-android-17
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 --name test --target android-23 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window -gpu off -no-boot-anim &
- android-wait-for-emulator
- adb devices
- adb shell input keyevent 82 &
script:
- echo $ADB_INSTALL_TIMEOUT
- android list target
- ./gradlew connectedAndroidTest
after_failure:
# Customize this line, 'android' is the specific app module name of this project. Shows log.
- export MY_MOD="SimpleLock"
- export MY_LOG_DIR="$(pwd)/app/build/reports/androidTests/connected/"
- pwd && cd "${MY_LOG_DIR:-.}" && pwd && ls -al
- sudo apt-get install -qq lynx && lynx --dump index.html > myIndex.log
- lynx --dump com.android.builder.testing.ConnectedDevice.html > myConnectedDevice.log
- lynx --dump com.android.builder.testing.html > myTesting.log
- for file in *.log; do echo "$file"; echo "====================="; cat "$file"; done || true
这是我的 Travis 输出: https://travis-ci.org/GarceGon/SimpleLock/builds/139367600
:app:connectedDebugAndroidTestUnable to install /home/travis/build/GarceGon/SimpleLock/app/build/outputs/apk/app-debug.apk
com.android.ddmlib.InstallException: Failed to establish session
at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:66)
at com.android.ddmlib.Device.installPackages(Device.java:901)
at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:119)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:121)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:48)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
com.android.builder.testing.ConnectedDevice > runTests[test(AVD) - 6.0] FAILED
com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to establish session
at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:129)
null
com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to establish session
at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:129)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:121)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:48)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.android.ddmlib.InstallException: Failed to establish session
at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:66)
at com.android.ddmlib.Device.installPackages(Device.java:901)
at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:119)
... 8 more
:app:connectedDebugAndroidTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:connectedDebugAndroidTest'.
> There were failing tests. See the report at: file:///home/travis/build/GarceGon/SimpleLock/app/build/reports/androidTests/connected/index.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: 2 mins 20.531 secs
The command "./gradlew connectedAndroidTest" exited with 1.
谢谢!