2016-09-09 61 views
5

試圖開始使用我的Android項目的Travis CI,但Travis在構建我的android項目時仍然失敗。特拉維斯CI - android編譯失敗。沒有連接的設備錯誤

原因:

:app:connectedDebugAndroidTest FAILED 

FAILURE: Build failed with an exception. 

* What went wrong: 

Execution failed for task ':app:connectedDebugAndroidTest'. 

> com.android.builder.testing.api.DeviceException: No connected devices! 

* Try: 

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

BUILD FAILED 

鏈接到特拉維斯: https://travis-ci.org/hypeapps/Episodie/builds/158706530

.travis.yml:

language: android 
jdk: 
    - oraclejdk8 
before_install: 
- chmod +x gradlew 
env: 
    global: 
    - ANDROID_API_LEVEL=24 
    - EMULATOR_API_LEVEL=21 
    - ANDROID_BUILD_TOOLS_VERSION=24.0.1 
    - ANDROID_ABI=google_apis/armeabi-v7a 
    - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default) 
android: 
    components: 
    - tools 
    - tools 
    - platform-tools 
    - build-tools-$ANDROID_BUILD_TOOLS_VERSION 
    - android-$ANDROID_API_LEVEL 
    - android-$EMULATOR_API_LEVEL 
    - extra 
    - add-on 
    - extra-google-m2repository 
    - extra-android-m2repository 

    # Google Play Services 
    - extra-google-google_play_services 
    # Support library 
    - extra-android-support 

    - addon-google_apis-google-$ANDROID_API_LEVEL 
    - addon-google_apis-google-$EMULATOR_API_LEVEL 

    - sys-img-armeabi-v7a-addon-google_apis-google-$ANDROID_API_LEVEL 
    - sys-img-armeabi-v7a-addon-google_apis-google-$EMULATOR_API_LEVEL 
    licenses: 
    - 'android-sdk-preview-license-52d11cd2' 
    - 'android-sdk-license-.+' 
    - 'google-gdk-license-.+' 
    before_script: 
    - echo no | android create avd --force -n test -t "Google Inc.:Google APIs:"$EMULATOR_API_LEVEL --abi $ANDROID_ABI 
    - emulator -avd test -no-skin -no-audio -no-window & 
    - android-wait-for-emulator 

鏈接到文件的gradle: build.gradle

Github的項目: GitHub

回答

5

解決的辦法是:

在頂部添加一行:

sudo: false 

創建模擬器管理:創建,啓動和等待

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 & 

現在特拉維斯CI工作。

+2

我可以問一個問題,爲什麼? – fangzhzh