Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Travis CI with Android

I've been looking at the Travis CI docs for Android, so I can learn how to start using Travis for my Android library. However, I don't understand a lot of what the documentation says...

So far, what I understand is:

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

The Travis CI docs also show additional components that can be used:

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

and it gives a more complete list here.

But what do these 'additional components' do/mean? I'm guessing that perhaps the extra-android-support component means the project will be built with the Android Support library, but what about the others?

I've had a look at Travis tests for Gradle, but I've seen other projects use script: ./gradlew check, script: ./gradlew clean build check, script: "./gradlew build", and some with no script at all. What does all of this mean?

like image 492
Farbod Salamat-Zadeh Avatar asked Jan 05 '16 20:01

Farbod Salamat-Zadeh


People also ask

What is Travis CI used for?

As a continuous integration platform, Travis CI supports your development process by automatically building and testing code changes, providing immediate feedback on the success of the change. Travis CI can also automate other parts of your development process by managing deployments and notifications.

Is Travis CI a CI tool?

Like Jenkins, Travis CI is also one of the early players in the CI/CD tools market. The tool is written in Ruby and is developed & maintained by the Travis CI community. Travis CI was earlier available only for GitHub hosted projects but now it also supports Bitbucket hosted projects.


1 Answers

With your .travis.yml file, you are configuring a machine to build and to run your code. In this file you have to specify all components that you need.

The doc shows all the SDK components that are already available (preinstalled). You don't need to specify them in your .travis.yml file, unless you want to force re-installation of this component.

Instead you have to specify the components that aren't preinstalled.
For example there is only the build-tools 21.1.1 on the list. It was a decision of the team because there are more frequent version updates for this component.

what do these 'additional components' do/mean?

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

These are the support library repositories (the same that you have to update with your SDK Manager) from which gradle downloads the support libraries added in the dependencies block of your build.gradle file.

To get a list of available exact component names and descriptions run the command android list sdk --no-ui --all --extended.
You will get somenthing like:

# 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

...

With your .travis.yml you have to tell travis how to check if your BUILD is SUCCESSFUL. With the script block you specify which commands to use to check the build.
If your project has a build.gradle file in the repository root, Gradle will be used to build it. It can be enough for you, it depends by your project.

The default command used with gradle is:

./gradlew build connectedCheck

but you can override it specyfing the script block.

More info here.

If you would like to see an output in travis-ci you can check this.

like image 184
Gabriele Mariotti Avatar answered Oct 05 '22 23:10

Gabriele Mariotti