Skip to content

therodrigocosta/docker-android

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Analytics Join the chat at https://gitter.im/budtmo/docker-android Build Status codecov Codacy Badge GitHub release FOSSA Status PRs Welcome

Docker-Android-Detox is a docker image based on the Docker-Android https://github.com/budtmo/docker-android .

However this image includes the configuration of the tool wix/Detox https://github.com/wix/Detox to allow the to test react-native apps on Android devices using detox

For now there are just one Docker image for just one device which is: Nexus 5 - API 23 - Android 6.0.1

Emulator - Nexus Device

Purposes

  1. Run UI tests for React-native apps with detox

Advantages compare with other docker-android projects

  1. noVNC to see what happen inside docker container
  2. Ability to test react-native apps
  3. First docker image that allows to run detox react-native tests
  4. Ability to connect to Selenium Grid
  5. Ability to control emulator from outside container by using adb connect
  6. Support real devices with screen mirroring
  7. Ability to record video during test execution for debugging
  8. Integrated with other cloud solutions, e.g. Genymotion Cloud
  9. Open source with more features coming

List of Docker images

OS Android API Browser Browser version Chromedriver Image Device name
Linux 6.0.1 23 browser 44.0 2.18 detox12-reactnative-nexus5-android6-api-23 nexus_5_6.0.1

List of Devices

Type Device Name
Phone Nexus 5

Requirements

Docker is installed in your system.

Quick Start

  1. Run Docker-Android

     ```bash
     docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e --name android-container ralves20/detox12-reactnative-nexus5-android6-api-23
     ```
    
  2. Verify the ip address of docker host.

    • For OSX, you can find out by using following command:

      docker-machine ip default
    • For different OS, localhost should work.

  3. Open http://docker-host-ip-address:6080 from web browser.

Running in your project with docker-compose

Pre-requirements:

  • You need to have docker-compose configurated on your computer.
  1. There is a docker-compose as an example on example/sample-compose-android.yml, you can use it as a basis for your usage.

  2. You are going to need to create an supervisord.conf file and using it as a volume for the supervisord inside the container, this is necessary because you need to modify supervisord section detox to run your detox tests. There is also an supervisord.conf example in example/sample-supervisord.conf.

  3. Modify your detox-test section on the bash command to execute the command that you need to run your tests.

Example:

[program:detox-test]
command=bash -c "yes | sdkmanager --licenses && cd /tmp/test && yarn detox:start & cd /tmp/test && yarn detox:build-android && cd /tmp/teste && yarn detox:test-android"
autorestart=false
stdout_logfile=/tmp/detox/detox.log
stderr_logfile=/tmp/detox/detox_err.log
priority=5
  1. Now in your project you need to modify your package.json in the detox section and set the device name as the name of the device you choose before.

Example:

      "android.emu.release": {
        "binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
        "build": "cd android && RN_SRC_EXT=e2e.js E2E=true ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..",
        "type": "android.emulator",
        "name": "nexus_5_6.0.1" //Here is the place where you need to set the device name
      }
  1. After generated the docker-compose file and generating your supervisord.conf, you can run your detox tests.

Custom configurations

This document contains custom configurations of Docker-Android that you might need, e.g. Proxy, Changing language on fly, etc.

Build Android project

Docker-Android can be used for building Android project and executing its unit test. This following steps will illustrate how to build Android project:

  1. Clone this sample test project.

    git clone git@github.com:googlesamples/android-testing.git
  2. Build the project

    docker run -it --rm -v $PWD/android-testing/ui/espresso/BasicSample:/root/tmp budtmo/docker-android-x86-8.1 tmp/gradlew build

Control Android connected to host (Emulator or Real Device)

  1. Create a docker container with this command

    $ docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -p 4723:4723 --name android-container-detox budtmo/docker-android-real-device
    
  2. Open noVNC http://localhost:6080

  3. Open terminal by clicking right on noVNC window >> Terminal emulator

  4. To connect to host's adb (make sure your host have adb and connected to the device.)

    $ adb -H host.docker.internal devices
    

    To specify port, just add -P port_number

    $ adb -H host.docker.internal -P 5037 devices
    
  5. Now your container can access your host devices. But, you need to add remoteAdbHost and adbPort desired capabilities to make detox can recognise those devices.

Control android emulator outside container

adb connect <docker-machine-ip-address>:5555

Note: You need to have Android Debug Bridge (adb) installed in your host machine.

SMS Simulation

  1. Using telnet

    • Find the auth_token and copy it.
    docker exec -it android-container cat /root/.emulator_console_auth_token
    • Access emulator using telnet and login with auth_token
    telnet <docker-machine-ip-address> 5554
    • Login with given auth_token from 1.step
    auth <auth_token>
    • Send the sms
    sms send <phone_number> <message>
  2. Using adb

    docker exec -it android-container adb emu sms send <phone_number> <message>
  3. You can also integrate it inside project using adb library.

Google Play Services and Google Play Store

Docker-Android contains Google Play Service (v12.8.74) and Google Play Store (v11.0.50). Both applications are downloaded from apklinker, so please be aware of it in case you use private/company account to that applications.

Jenkins

This document gives you information about custom plugin that supports Docker-Android.

VMWARE

This document shows you how to configure Virtual Machine on VMWARE to be able to run Docker-Android.

Cloud

This document contains information about deploying Docker-Android on cloud services.

Genymotion

For you who do not have ressources to maintain the simulator or to buy machines or need different device profiles, you need to give a try to Genymotion Cloud. Docker-Android is integrated with Genymotion on different cloud services, e.g. Genymotion Cloud, AWS, GCP, Alibaba Cloud. Please follow this document or this blog for more detail.

Troubleshooting

All logs inside container are stored under folder /var/log/supervisor. you can print out log file by using docker exec. Example:

docker exec -it android-container tail -f /var/log/supervisor/docker-android.stdout.log

Emulator Skins

The Emulator skins are taken from Android Studio IDE and Samsung Developer Website

Security

All docker images are protected by Polyverse by scrambling the Linux packages. For more information please read this

Special Thanks

LICENSE

See License

FOSSA Status

About

Android in docker solution with noVNC supported and video recording

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 47.9%
  • Python 42.5%
  • HCL 9.6%