Circle.ci 上带有 Google Play 服务的 Android AVD

标签 android android-emulator google-play-services android-virtual-device circleci

我正在使用 circle.ci 在模拟器上测试我的代码。

我有一些浓缩咖啡测试使用来自谷歌的 map 和地点 api。这些测试不适用于 circle.ci 给出的模拟器

所以我试着自己做,在circle.yml里

machine:
  environment:
    PATH: "~/$CIRCLE_PROJECT_REPONAME/gradle-2.9/bin:$PATH"
    TERM: "dumb"
    ADB_INSTALL_TIMEOUT: "10"
    GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'

dependencies:
  pre:
    - android list targets
    - wget "https://services.gradle.org/distributions/gradle-2.9-bin.zip"; unzip gradle-2.9-bin.zip
    - android list sdk -a -e
    - echo y | android update sdk --no-ui --all --filter build-tools-23.0.2
    - echo y | android update sdk --no-ui --all --filter tool,android-22,extra-android-m2repository,extra-android-support,extra-google-google_play_services,extra-google-m2repository,addon-google_apis-google-22
    - echo y | android update sdk --no-ui --all --filter sys-img-armeabi-v7a-google_apis-22
test:
  override:
    - echo no | android create avd -n avd22 -t 12 --abi google_apis/armeabi-v7a
    - emulator -avd avd22 -no-audio -no-window:
        background: true
        parallel: true

可悲的是,即使我在运行 android update sdk --no-ui --all --filter sys-img-armeabi-v7a-google_apis-22 时,如果我执行 android列出目标 看来我的图片不可用:

id: 12 or "Google Inc.:Google APIs:22"
     Name: Google APIs
     Type: Add-On
     Vendor: Google Inc.
     Revision: 1
     Description: Android + Google APIs
     Based on Android 5.1.1 (API level 22)
     Libraries:
      * com.google.android.media.effects (effects.jar)
          Collection of video effects
      * com.android.future.usb.accessory (usb.jar)
          API for USB Accessories
      * com.google.android.maps (maps.jar)
          API for Google Maps
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.

如果有人有在 circle.ci 上使用带有播放服务的模拟器的解决方案,那对我来说真的很有用...

最佳答案

经过大量尝试,我终于可以使用此配置文件创建带有播放服务的 Android AVD:

machine:
  environment:
    PATH: "~/$CIRCLE_PROJECT_REPONAME/gradle-2.9/bin:$PATH"
    TERM: "dumb"
    ADB_INSTALL_TIMEOUT: "10"
    GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
dependencies:
  pre:
    - echo y | android update sdk --no-ui --all --filter tools
    - echo y | android update sdk --no-ui --all --filter platform-tools
    - echo y | android update sdk --no-ui --all --filter extra-android-m2repository
    - echo y | android update sdk --no-ui --all --filter extra-android-support
    - echo y | android update sdk --no-ui --all --filter extra-google-google_play_services
    - echo y | android update sdk --no-ui --all --filter extra-google-m2repository
    - echo y | android update sdk --no-ui --all --filter android-22
    - echo y | android update sdk --no-ui --all --filter build-tools-23.0.2
    - echo y | android update sdk -a -u -t sys-img-armeabi-v7a-google_apis-22
    - android list targets
test:
  override:
    - echo no | android create avd -n custom-android22-googleapis -t "android-22" --abi google_apis/armeabi-v7a
    - android list avd
    - emulator -avd custom-android22-googleapis -no-audio -no-window:
        background: true
        parallel: true
    # wait for emulator to have booted
    - circle-android wait-for-boot
    # Sleeping isn't a brilliant fix...
    - sleep 30
    - fb-adb rcmd screencap -p > $CIRCLE_ARTIFACTS/screen-$(date +"%T").png
    - adb shell input keyevent 82
    - ./gradlew connectedAndroidTest -PdisablePreDex --console=plain --info
    #- fb-adb devices
    - fb-adb rcmd screencap -p > $CIRCLE_ARTIFACTS/screen-$(date +"%T").png

关于Circle.ci 上带有 Google Play 服务的 Android AVD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37728253/

相关文章:

android - ListView 中每一列的单独点击事件

android - Assets 中的 BitmapFactory.decodeStream 在 Android 7 上有时会失败

android - 在 Windows 中从 Jenkins 启动 android 模拟器 adb(运行仪器测试,模拟器不会出现)

屏幕锁定时 Android 收不到位置更新

android - 统一注销谷歌玩游戏服务

javascript - Highcharts - 数据不会加载到 Android WebView 上的图表中

android - 为 WebTokens 身份验证改造自定义客户端

Android Http 从 Servlet 获取字符串数据

java - Webview 在 android 2.2 中加载 html 而不是 android 2.1

无法安装 Android Play Services Leaderboard (BaseGameUtils)