使用 Travis CI 和 Android

Using Travis CI with Android

我一直在查看 Travis CI docs for Android,因此我可以了解如何开始将 Travis 用于我的 Android 库。但是,我不明白文档说的很多内容...

到目前为止,我的理解是:

language: android  # this means the project will be built in an Android environment

android:
  components:
    - tools               # will be built with latest version of Android SDK tools
    - platform-tools      # ''
    - build-tools-23.0.1  # build tools version of my project
    - android-23          # Android SDK version of my project

Travis CI 文档还显示了可以使用的其他组件:

# Additional components
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- addon-google_apis-google-19

它给出了一个更完整的列表 here

但是这些 'additional components' do/mean 是做什么的? 我猜也许 extra-android-support 组件意味着项目将用Android 支持库,但是其他的呢?

我看过 Travis tests for Gradle,但我看到其他项目使用 script: ./gradlew checkscript: ./gradlew clean build checkscript: "./gradlew build",还有一些没有 script 完全没有。 这一切意味着什么?

使用您的 .travis.yml 文件,您正在配置一台机器来构建和 运行 您的代码。在此文件中,您必须指定所需的所有组件。

文档显示了所有可用(预安装)的 SDK 组件。您不需要在 .travis.yml 文件中指定它们,除非您想要强制 re-installation 该组件。

相反,您必须指定未预安装的组件。
例如,列表中只有 build-tools 21.1.1。这是团队的决定,因为此组件的版本更新更频繁。

what do these 'additional components' do/mean?

- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository

这些是支持库存储库(与您必须使用 SDK 管理器更新的存储库相同),gradle 从中下载添加到 build.gradle 文件的依赖项块中的支持库。

要获取可用的确切组件名称和描述的列表 运行 命令 android list sdk --no-ui --all --extended
你会得到类似的东西:

# Check Android SDK tools: http://developer.android.com/tools/sdk/tools-notes.html
# Check Android SDK Platform-tools: http://developer.android.com/tools/revisions/platforms.html
tools
platform-tools

# Check BuildTools: http://developer.android.com/tools/revisions/build-tools.html
build-tools-23.0.1

# The API to be used to compile
# Check APIs: http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels

android-23
android-22
android-21
android-20
android-19
android-18
android-17
android-16
....

# The system images if you need to run emulator during your tests

sys-img-armeabi-v7a-android-23
sys-img-x86-android-23
....

# Google repository from which download the dependencies

# Check extras: http://developer.android.com/sdk/installing/adding-packages.html#GetSupportLib
extra-android-m2repository
extra-android-support

# Check more extras: http://developer.android.com/sdk/installing/adding-packages.html#GetGoogle
extra-google-m2repository
extra-google-google_play_services

extra-google-admob_ads_sdk
extra-google-analytics_sdk_v2
extra-google-gcm
extra-google-google_play_services_froyo
.....

# Source file
source-23
source-22
source-21

...

对于 .travis.yml,您必须告诉 travis 如何检查您的 BUILD 是否成功。使用 script 块,您可以指定使用哪些命令来检查构建。
如果您的项目在存储库根目录中有一个 build.gradle 文件,将使用 Gradle 来构建它。这对你来说足够了,这取决于你的项目。

与 gradle 一起使用的默认命令是:

./gradlew build connectedCheck

但您可以通过指定脚本块来覆盖它。

更多信息here

如果您想在 travis-ci 中查看输出,您可以检查 this