With the recent update to Android SDK and the Gradle plugin, we have been seeing an increase in test timeouts. Part of this appears due to our older emulator AVD images not having Google Play Services APIs installed.
While we work to get these updated, here are instructions on how to create a newer AVD with the Google Play Services APIs installed:
dependencies:
pre:
- echo y | android update sdk --no-ui --all --filter tools
- echo y | android update sdk --no-ui --all --filter platform-tools
- echo y | android update sdk --no-ui --all --filter extra-android-m2repository
- echo y | android update sdk --no-ui --all --filter extra-android-support
- echo y | android update sdk --no-ui --all --filter extra-google-google_play_services
- echo y | android update sdk --no-ui --all --filter extra-google-m2repository
- echo y | android update sdk --no-ui --all --filter android-24
- echo y | android update sdk --no-ui --all --filter build-tools-24.0.1
- echo y | android update sdk -a -u -t sys-img-armeabi-v7a-google_apis-24
test:
override:
- echo no | android create avd -n custom-android24-googleapis -t "android-24" --abi google_apis/armeabi-v7a
- android list avd
- emulator -avd custom-android24-googleapis -no-window:
background: true
parallel: true
# wait for emulator to have booted
- circle-android wait-for-boot
Couple of things to note: -no-audio
has been removed as it is not a valid flag under the ARM image and will cause the emulator to not load. Also, the tools
and platform-tools
tools will fetch the latest versions, so if you want to use a certain version you will need to change those. You can run android list sdk --all --extended
to get a full list of everything that is available.
You will also want to make sure you are running the latest Gradle plugin, otherwise your tests may fail stating they can find no compatible emulator image.
Thanks to How do you create android emulator with google apis? for the instructions on how to fetch the ARM image and create the AVD.
One final troubleshooting tip: any command run with the background: true
modifier writes it’s stderr file to the artifacts, so even if you cancel a build you can check there to see if the emulator threw any errors.