使用Google API"选择目标无效--abi armeabi-v7a"

Sea*_*eau 16 android travis-ci

我正在尝试将Android项目从使用API​​ Level 19 SDK和构建工具更新到最新的API Level 21,包括Google API.在此更新之前,Travis上的所有内容都运行良好(例如,请参阅此版本).

当我使用新的API级别运行时,我看到以下错误:

0.42s$ echo no | android create avd --force -n test -t "Google Inc.:Google APIs:"$ANDROID_API_LEVEL --abi $ANDROID_ABI
Valid ABIs: no ABIs.
Error: Invalid --abi armeabi-v7a for the selected target.
The command "echo no | android create avd --force -n test -t "Google Inc.:Google APIs:"$ANDROID_API_LEVEL --abi $ANDROID_ABI" failed and exited with 1
Run Code Online (Sandbox Code Playgroud)

有关完整的Travis输出,请参阅此构建.

这是我的.travis.yml:

language: android
jdk: oraclejdk7
# Turn off caching to avoid any caching problems
cache: false
# Use the Travis Container-Based Infrastructure (see #203)
sudo: false
env:
  global:
    - ANDROID_API_LEVEL=21
    - ANDROID_BUILD_TOOLS_VERSION=21.1.2
    - ANDROID_ABI=armeabi-v7a

android:
  components:
    - platform-tools
    - tools
    - build-tools-$ANDROID_BUILD_TOOLS_VERSION
    - android-$ANDROID_BUILD_TOOLS_VERSION
    # For Google Maps API v1
    - addon-google_apis-google-$ANDROID_API_LEVEL
    # Google Play Services
    - extra-google-google_play_services
    # Support library
    - extra-android-support
    # Latest artifacts in local repository
    - extra-google-m2repository
    - extra-android-m2repository
    # Specify at least one system image,
    - sys-img-armeabi-v7a-android-$ANDROID_BUILD_TOOLS_VERSION

before_script:
  # Create and start emulator
  - echo no | android create avd --force -n test -t "Google Inc.:Google APIs:"$ANDROID_API_LEVEL --abi $ANDROID_ABI
  - emulator -avd test -no-skin -no-audio -no-window &

script:
  - ./wait_for_emulator
  - ./gradlew connectedCheck -PdisablePreDex
Run Code Online (Sandbox Code Playgroud)

我的build.gradle就在这里.

同样,我在新的Travis构建中唯一改变的是API级别和构建工具级别.

Sea*_*eau 22

显然,Google API系统映像和ABI参数的名称已更改:

  • ABI = armeabi-v7agoogle_apis/armeabi-v7a
  • 系统图片= sys-img-armeabi-v7a-android-21sys-img-armeabi-v7a-addon-google_apis-google-21

我通过更新ANDROID_ABI系统映像的变量和组件名称来修复此问题- 新值为:

- ANDROID_ABI=google_apis/armeabi-v7a
...
# Specify at least one system image,
- sys-img-armeabi-v7a-addon-google_apis-google-$ANDROID_API_LEVEL
Run Code Online (Sandbox Code Playgroud)

以下是整个上下文部分:

env:
  global:
    - ANDROID_API_LEVEL=21
    - ANDROID_BUILD_TOOLS_VERSION=21.1.2
    - ANDROID_ABI=google_apis/armeabi-v7a

android:
  components:
    - platform-tools
    - tools
    - build-tools-$ANDROID_BUILD_TOOLS_VERSION
    - android-$ANDROID_API_LEVEL
    # For Google Maps API v1
    - addon-google_apis-google-$ANDROID_API_LEVEL
    # Google Play Services
    - extra-google-google_play_services
    # Support library
    - extra-android-support
    # Latest artifacts in local repository
    - extra-google-m2repository
    - extra-android-m2repository
    # Specify at least one system image
    - sys-img-armeabi-v7a-addon-google_apis-google-$ANDROID_API_LEVEL
Run Code Online (Sandbox Code Playgroud)

在这些更改之后,它会成功构建.

编辑2016年9月12日

显然,2016年中期还有另一个变化导致了同样的问题.例如,这是一个失败的构建,具有相同的错误消息.

修复Travis构建需要进行以下更改:

  • 添加单独的ANDOID_TAG ABI标记变量
  • 获取新工具repository-11.xml并安装Android SDK工具25.1.x的重复工具
  • 更改系统映像名称以匹配新的Android SDK
  • 更改模拟器启动命令以使用新的ABI标记变量来指定Google API

例如:

- ANDROID_ABI=google_apis/armeabi-v7a

...变成:

- ANDROID_ABI=armeabi-v7a

- ANDROID_TAG=google_apis

- tools 需要列出两次.

系统映像:

- sys-img-armeabi-v7a-addon-google_apis-google-23

- sys-img-armeabi-v7a-addon-google_apis-google-23

......需要改为:

- sys-img-armeabi-v7a-google_apis-23

- sys-img-armeabi-v7a-google_apis-23

启动模拟器的行改为:

- echo no | android create avd --force -n test -t "Google Inc.:Google APIs:23" --abi $ANDROID_ABI

...至:

- echo no | android create avd --force -n test -t "android-23" --abi $ANDROID_ABI --tag $ANDROID_TAG

请参阅此提交以获取需要更改的更改集,此文件用于完整工作的脚本,有关详细信息,请参阅https://github.com/travis-ci/travis-ci/issues/6122#issuecomment-239073557.

感谢@Ardock的修复!

编辑2016年11月28日

我似乎API Level 23模拟器目前没有使用上面的Travis工作 - android create avd --force -n test -t "android-23" --abi "armeabi-v7a" --tag "google_apis"产生错误Error: Invalid --tag google_apis for the selected target. 有关更多详细信息,请参阅https://github.com/OneBusAway/onebusaway-android/issues/720.

此外,显然ARM ABI目前不适用于API级别24或25(Android 7.1.1) - 请参阅此问题以获取SDK Manager的屏幕截图.

已将问题发布到Android Studio Google+社区:https: //plus.google.com/+SeanBarbeau/posts/adNGGtJFhvi?sfc = true


Pan*_*nts 9

派对有点晚,但这仍然是一个问题,我发现它的唯一方法是在模拟器上使用android-22.

这是我的.travis.yml供参考.

language: android
notifications:
  email: false
before_install:
  - sudo apt-get -qq update
  - sudo apt-get install -y pax
env:
  global:
  - ANDROID_API_LEVEL=26
  - ANDROID_BUILD_TOOLS_VERSION=26.0.1
  - ANDROID_EMU_API_LEVEL=22
  - ANDROID_ABI=armeabi-v7a
  - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default)
  - QEMU_AUDIO_DRV=none # Remove audio
cache:
  directories:
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/
    - $HOME/.android/build-cache
android:
  components:
  - tools
  - platform-tools
  - tools
  - build-tools-$ANDROID_BUILD_TOOLS_VERSION
  - android-$ANDROID_API_LEVEL
  - android-$ANDROID_EMU_API_LEVEL
  - extra-android-support
  - sys-img-$ANDROID_ABI-google_apis-$ANDROID_EMU_API_LEVEL
before_script:
  - echo -e "Host github.com\n\tHostName github.com\n\tUser git\n\tIdentityFile ~/.ssh/id_travisci\n" >> ~/.ssh/config
  - echo no | android create avd --force -n test -t android-$ANDROID_EMU_API_LEVEL --abi google_apis/$ANDROID_ABI
  - emulator -avd test -no-window &
  - android-wait-for-emulator
  - adb shell input keyevent 82 &
script:
  - ./gradlew clean installDebug
  - ./gradlew check
  - ./gradlew testDebugUnitTest
  - ./gradlew connectedDebugAndroidTest
Run Code Online (Sandbox Code Playgroud)