Skip to content

Commit

Permalink
Merge pull request #20 from ozmium/patch-1
Browse files Browse the repository at this point in the history
Issue #18 fix patch: Remove pre-installed x86_64 emulator. Explain how to create and launch an ARM emulator
  • Loading branch information
mingchen authored Oct 13, 2018
2 parents d7ce3ea + 54a8f04 commit 6bf8482
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,7 @@ RUN echo "installing sdk tools" && \
"add-ons;addon-google_apis-google-17" \
"add-ons;addon-google_apis-google-16" && \
echo "installing emulator " && \
yes | "$ANDROID_HOME"/tools/bin/sdkmanager "emulator" && \
echo "installing system image with android 25 and google apis" && \
yes | "$ANDROID_HOME"/tools/bin/sdkmanager \
"system-images;android-25;google_apis;x86_64"
yes | "$ANDROID_HOME"/tools/bin/sdkmanager "emulator"

# Copy sdk license agreement files.
RUN mkdir -p $ANDROID_HOME/licenses
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,35 @@ Here is an example of `bitbucket-pipelines.yml`
If gradlew is marked as executable in your repository as recommended, remove the `chmod` command.


### Run an Android emulator in the Docker build machine

Using guidelines from https://medium.com/@AndreSand/android-emulator-on-docker-container-f20c49b129ef and https://spin.atomicobject.com/2016/03/10/android-test-script/ and https://paulemtz.blogspot.com/2013/05/android-testing-in-headless-emulator.html , you can use a script to create and launch an ARM emulator, which can be used for running integration tests or instrumentation tests or unit tests:

```shell
#!/bin/bash

# Add missing folder to the PATH, to use sdkmanager and avdmanager
ANDROID_TOOLS=$ANDROID_HOME/tools/bin
PATH=$ANDROID_TOOLS:$PATH

# Download an ARM system image to create an ARM emulator.
sdkmanager "system-images;android-16;default;armeabi-v7a"

# Create an ARM AVD emulator, with a 100 MB SD card storage space. Echo "no"
# because it will ask if you want to use a custom hardware profile, and you don't.
# https://medium.com/@AndreSand/android-emulator-on-docker-container-f20c49b129ef
echo "no" | avdmanager create avd \
-n Android_4.1_API_16 \
-k "system-images;android-16;default;armeabi-v7a" \
-c 100M \
--force

# Launch the emulator in the background
$ANDROID_HOME/emulator/emulator -avd Android_4.1_API_16 -no-skin -no-audio -no-window -no-boot-anim -gpu off &
```

Note that x86_64 emulators are not currently supported. See [Issue #18](https://github.com/mingchen/docker-android-build-box/issues/18) for details.

## Docker Build Image

If you want to build the docker image by yourself, you can use following command.
Expand Down

0 comments on commit 6bf8482

Please sign in to comment.