Travis-CI implementation of Android SDK 25 with Em

2019-07-27 03:31发布

问题:

I need help with implementing Travis-CI in my android repository.

My Project is compiled with SDK 25 but is downwards compatible to Version 21.

How do I have to change my .travis.yml to run an android emulator thats compatible with that SDK Version?

.travis.yml:

language: android
jdk: oraclejdk8
android:
  components:
    - tools # to get the new `repository-11.xml`
    - tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943)
    - platform-tools
    - extra-google-google_play_services
    - extra-google-m2repository
    - extra-android-m2repository
    - addon-google_apis-google-19
    - build-tools-25.0.0
    - android-25

  #  - sys-img-armeabi-v7a-android-22

before_script:
    #- android update sdk -a --no-ui --filter sys-img-armeabi-v7a-android-25,sys-img-x86_64-android-25
    # - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
    # - emulator -avd test -no-skin -no-audio -no-window &
    # - android-wait-for-emulator
    # - adb shell input keyevent 82 &

script:
    # - ./gradlew build connectedCheck

Right now it exits with the "no connected devices"-Error, which makes sense, because there is no emulator running. But when I tried it using the android-22 emulator it also crashed with an error like "Android SDK 22 not installed"

EDIT: The commented lines in the travis.yml didn't work, that's why they are commented out.

回答1:

For such properties that we have in our project:

compileSdkVersion 25
minSdkVersion 21
targetSdkVersion 25

We use such emulator:

echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a --skin 480x800

No special deps are required in travis.yml besides:

- tools
- platform-tools
- build-tools-25.0.1
- android-25
- extra-android-m2repository

Here is out repository with min SDK 19: https://github.com/elpassion/el-peon-android



回答2:

I only answer the android-22 part because I'm not using Travis-ci with recent versions of Android:

language: android
jdk: oraclejdk8
android:
  components:
    - tools # to get the new `repository-11.xml`
    - tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943)
    - platform-tools
    - extra-google-google_play_services
    - extra-google-m2repository
    - extra-android-m2repository
    - build-tools-25.0.0
    - android-25
    - android-22 # Android platform used by your alternative emulator
    - sys-img-armeabi-v7a-android-22

before_script:
    - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
    - emulator -avd test -no-skin -no-audio -no-window &
    - android-wait-for-emulator
    - adb shell input keyevent 82 &

script:
    - ./gradlew build connectedCheck