Skip to content

Commit e7182a7

Browse files
Merge branch 'master' into km-TDOC-324
2 parents 16a3cb3 + 9b9c61e commit e7182a7

File tree

1 file changed

+59
-29
lines changed

1 file changed

+59
-29
lines changed

user/languages/android.md

Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ Android builds are not available on the macOS environment.
1414

1515
### Overview
1616

17-
> Android builds are officially supported only on our Trusty Build environment at this time; hence, you'll need to explicitly specify `dist: trusty` in your .travis.yml file.
17+
> Android builds are officially supported on our Bionic, Focal, and Jammy build environments; hence, you'll need to explicitly specify `dist: bionic`, `dist: focal`, or `dist: jammy` in your .travis.yml file.
1818
1919
Travis CI environment provides a large set of build tools for JVM languages with [multiple JDKs, Ant, Gradle, Maven](/user/languages/java/#overview), [sbt](/user/languages/scala/#projects-using-sbt) and [Leiningen](/user/languages/clojure/).
2020

2121
By setting
2222

2323
```yaml
2424
language: android
25-
dist: trusty
25+
dist: focal # or dist: jammy, dist: bionic
2626
```
2727
{: data-file=".travis.yml"}
2828
29-
in your `.travis.yml` file, your project will be built in the Android environment which provides [Android SDK Tools](http://developer.android.com/tools/sdk/tools-notes.html) 25.2.3.
29+
in your `.travis.yml` file, your project will be built in the Android environment which provides [Android SDK Tools](http://developer.android.com/tools/sdk/tools-notes.html).
3030

3131
Here is an example `.travis.yml` for an Android project:
3232

3333
```yaml
3434
language: android
35-
dist: trusty
35+
dist: focal
3636
android:
3737
components:
3838
# Uncomment the lines below if you want to
@@ -41,10 +41,10 @@ android:
4141
# - platform-tools
4242
4343
# The BuildTools version used by your project
44-
- build-tools-26.0.2
44+
- build-tools-30.0.0
4545
4646
# The SDK version used to compile your project
47-
- android-26
47+
- android-30
4848
4949
# Additional components
5050
- extra-google-google_play_services
@@ -53,7 +53,7 @@ android:
5353
5454
# Specify at least one system image,
5555
# if you need to run emulator(s) during your tests
56-
- sys-img-x86-android-26
56+
- sys-img-x86-android-30
5757
- sys-img-armeabi-v7a-android-17
5858
```
5959
{: data-file=".travis.yml"}
@@ -64,28 +64,60 @@ In your `.travis.yml`, you can define the list of SDK components to be installed
6464

6565
```yaml
6666
language: android
67-
dist: trusty
67+
dist: focal
6868
android:
6969
components:
70-
- build-tools-26.0.2
71-
- android-26
72-
- extra
70+
- build-tools-30.0.0
71+
- android-30
72+
- extras;google;google_play_services
73+
- extras;google;m2repository
74+
- extras;android;m2repository
7375
```
7476
{: data-file=".travis.yml"}
7577

7678
The exact component names must be specified (filter aliases like `add-on` or `extra` are also accepted). To get a list of available exact component names and descriptions run the command `sdkmanager --list` (preferably in your local development machine).
7779

80+
Here are specific extra components you can install:
81+
82+
```yaml
83+
android:
84+
components:
85+
# Google Play services
86+
- extras;google;google_play_services
87+
88+
# Google Repository
89+
- extras;google;m2repository
90+
91+
# Android Support Repository
92+
- extras;android;m2repository
93+
94+
# Android Support Library
95+
- extras;android;support
96+
97+
# Google Analytics libraries
98+
- extras;google;analytics_sdk_v2
99+
100+
# Google Cloud Messaging libraries
101+
- extras;google;gcm
102+
103+
# Google USB Driver (Windows only)
104+
- extras;google;usb_driver
105+
106+
# Intel x86 Emulator Accelerator (HAXM installer)
107+
- extras;intel;Hardware_Accelerated_Execution_Manager
108+
```
109+
78110
#### Deal with Licenses
79111

80112
By default, Travis CI will accept all the requested licenses, but it is also possible to define a white list of licenses to be accepted, as shown in the following example:
81113

82114
```yaml
83115
language: android
84-
dist: trusty
116+
dist: focal
85117
android:
86118
components:
87-
- build-tools-26.0.2
88-
- android-26
119+
- build-tools-30.0.0
120+
- android-30
89121
- add-on
90122
- extra
91123
licenses:
@@ -103,22 +135,20 @@ While the following components are preinstalled, the exact list may change witho
103135

104136
- tools
105137
- platform-tools
106-
- build-tools-25.0.2
107-
- android-25
108-
- extra-google-google_play_services
109-
- extra-google-m2repository
110-
- extra-android-m2repository
138+
- build-tools;30.0.0
139+
- platforms;android-30
140+
- extras;google;google_play_services
141+
- extras;google;m2repository
142+
- extras;android;m2repository
111143

112144
### Create and Start an Emulator
113145

114-
**Warning:** At the moment, these steps are not fully supported by Travis CI Android builder.
115-
116-
If you feel adventurous, you may use the script [`/usr/local/bin/android-wait-for-emulator`](https://github.com/travis-ci/travis-cookbooks/blob/precise-stable/ci_environment/android-sdk/files/default/android-wait-for-emulator) and adapt your `.travis.yml` to make this emulator available for your tests. For example:
146+
If you need to use an emulator for your tests, you can use the script [`/usr/local/bin/android-wait-for-emulator`](https://github.com/travis-ci/travis-cookbooks/blob/precise-stable/ci_environment/android-sdk/files/default/android-wait-for-emulator) and adapt your `.travis.yml` to make this emulator available for your tests. For example:
117147

118148
```yaml
119149
# Emulator Management: Create, Start and Wait
120150
before_script:
121-
- echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a -c 100M
151+
- echo no | android create avd --force -n test -t android-30 --abi armeabi-v7a -c 100M
122152
- emulator -avd test -no-audio -no-window &
123153
- android-wait-for-emulator
124154
- adb shell input keyevent 82 &
@@ -133,7 +163,7 @@ If your project is built with Ant or any other build tool that does not automati
133163

134164
```yaml
135165
language: android
136-
dist: trusty
166+
dist: focal
137167
install: ant deps
138168
```
139169
{: data-file=".travis.yml"}
@@ -198,9 +228,9 @@ As for any JVM language, it is also possible to [test against multiple JDKs](/us
198228

199229
For Android projects, `env` and `jdk` can be given as arrays to construct a build matrix.
200230

201-
## Build Android projects on new build environments
231+
## Build Android projects on different build environments
202232

203-
The `dist: trusty` build environment is the only supported build environment for Android but if you would like to build on newer build environments e.g. `dist: jammy`, you can exercise your access to the Travis CI build environments and install required packages and tools. An example .travis.yml config can be reviewed below:
233+
Android projects are supported on `dist: bionic`, `dist: focal`, and `dist: jammy` build environments. If you have specific requirements for other build environments, you can install required packages and tools as shown in this example:
204234

205235
```yaml
206236
os: linux
@@ -227,15 +257,15 @@ before_install:
227257
install:
228258
# INSTALL REQUIRED ANDROID SDK TOOLS
229259
- sdkmanager --sdk_root=$ANDROID_HOME --list | awk '/Installed/{flag=1; next} /Available/{flag=0} flag'
230-
- yes | sdkmanager --sdk_root=$ANDROID_HOME --install "platform-tools" "platforms;android-33" "build-tools;33.0.2" "emulator" "system-images;android-33;google_apis;x86_64"
260+
- yes | sdkmanager --sdk_root=$ANDROID_HOME --install "platform-tools" "platforms;android-30" "build-tools;30.0.0" "emulator" "system-images;android-30;google_apis;x86_64"
231261
- sdkmanager --list --sdk_root=$ANDROID_HOME | awk '/Installed/{flag=1; next} /Available/{flag=0} flag'
232262
# CREATE AVD
233-
- echo "no" | avdmanager --verbose create avd --force --name "my_android_33" --package "system-images;android-33;google_apis;x86_64" --tag "google_apis" --abi "x86_64"
263+
- echo "no" | avdmanager --verbose create avd --force --name "my_android_30" --package "system-images;android-30;google_apis;x86_64" --tag "google_apis" --abi "x86_64"
234264
- sudo chmod -R 777 /dev/kvm
235265
# Start emulator in background and wait for it to start
236266
- adb kill-server && adb start-server &
237267
- sleep 15 # sleep values may require adjusting depending on the specific build environment
238-
- emulator @my_android_33 -no-audio -no-window &
268+
- emulator @my_android_30 -no-audio -no-window &
239269
- sleep 60
240270
241271
script:

0 commit comments

Comments
 (0)