我正在尝试将 Android 项目从使用 API 级别 19 SDK 和构建工具更新到最新的 API 级别 21,包括 Google API。在此更新之前,Travis 上的一切都运行良好(例如,参见 this build)。
当我使用新的 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
见 this build获取完整的 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
我的 build.gradle 是 here .
同样,我在新的 Travis 构建中唯一改变的是 API 级别和构建工具级别。
最佳答案
显然 Google API 系统镜像和 ABI 参数的名称已更改:
- ABI =
armeabi-v7a
到google_apis/armeabi-v7a
- 系统镜像 =
sys-img-armeabi-v7a-android-21
到sys-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
这是整个部分的上下文:
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
在这些更改之后,它 builds successfully .
2016 年 9 月 12 日编辑
显然,2016 年年中发生了另一个变化,导致了同样的问题。例如,here's a failed build有同样的错误信息。
修复 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
启动模拟器的行从:
- 回显不 | android create avd --force -n test -t "Google Inc.:Google APIs:23"--abi $ANDROID_ABI
...到:
- 回显不 | android create avd --force -n test -t "android-23"--abi $ANDROID_ABI --tag $ANDROID_TAG
见 this commit对于需要更改的变更集,this file如需完整的脚本,请参阅 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) - 请参阅 this issue获取 SDK Manager 的屏幕截图。
在此处向 Android Studio Google+ 社区发布问题: https://plus.google.com/+SeanBarbeau/posts/adNGGtJFhvi?sfc=true
关于android - "Invalid --abi armeabi-v7a for the selected target"使用 Google API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28751111/