Git Product home page Git Product logo

docker-android-emulator's Introduction

Android emulator Image

The use of this Docker image simplifies the process of running an Android emulator within a Docker container. This can be achieved through a few basic commands or by utilizing a simple Docker compose file. The image includes the latest version of the Android SDK, as well as the Appium server, which allows for the execution of mobile automation tests. for more info --> https://medium.com/@Amr.sa/running-android-emulator-in-a-docker-container-19ecb68e1909

Feature

  • Run android emulator in headless or in headed mode (through VNC)
  • Support Appium driver
  • Come with the latest JDK lts.

Setup

Manual execution

Down below is the list of the main scripts to launch the relevant service, certain environment variables should be passed during starting the container.

  1. build the docker image :

    docker build -t android-emulator .
    

    OR for customized image

    docker build \
    --build-arg ARCH=x86_64  \
    --build-arg TARGET=google_apis_playstore\
    --build-arg API_LEVEL=31 \
    --build-arg BUILD_TOOLS=31.0.0 \
    --build-arg EMULATOR_DEVICE="Nexus 6" \
    --build-arg EMULATOR_NAME=nexus \
    -t my-android-image .  
    
  2. Start your container:

    docker run -it --privileged -d -p 5900:5900 --name androidContainer --privileged android-emulator  
    
  3. Launch the appium session :

    docker exec --privileged -it androidContainer bash -c "appium -p 5900"
    

    OR

    docker exec --privileged  -it androidContainer bash -c "./start_appium.sh"
    
  4. Start the emulator in headless mode :

    docker exec --privileged -it -e EMULATOR_TIMEOUT=300 androidContainer bash -c "./start_emu_headless.sh"
    
  5. Starting VNC server:

    docker exec --privileged -it androidContainer bash -c "./start_vnc.sh"
    

Launch emulator in headed mode

  1. The following command must be used to initiate the Docker container:

    docker run -it -d -p 5900:5900 --name androidContainer -e VNC_PASSWORD=password --privileged android-emulator
    
  2. Instantiate the VNC service by running:

    docker exec --privileged -it androidContainer bash -c "./start_vnc.sh"
    
  3. Connect to the VNC server via remmina or any VNC viewer, on:

    localhost:5900
    
  4. Open dash terminal in vnc viewer and right the following command:

    #: ./start_emu.sh
    

vnc gif

*Note:

  • The "start_emu.sh" script will start the emulator in a visible mode, therefore it should not be used for integration with a pipeline such as GitHub Actions or CircleCI. Instead, use the "start_emu_headless.sh" script.
  • By default, Running emulator is 'Nexus 6' (emulator name: nexus) (Android 13)
  • It is not necessary to launch all services in the docker-compose file, instead you should only enable the services you require, and comment out the others in the file.

Using Docker-compose

The Docker Compose file simplifies the process of starting the service. It includes multiple services, such as launching the emulator with the Appium instance or launching the VNC server. You have the flexibility to enable or disable any service based on your needs.

docker compose up

Environments

When manually starting the container, ensure to set the necessary environment variables for proper operation

Environments Description Required Service
APPIUM_PORT Port for the appium instance optional Android
VNC_PASSWORD Password needed to connect to VNC Server optional VNC
OSTYPE linux or macos/darwin optional Android
EMULATOR_TIMEOUT emulator booting up timeoue, default 240 second optional Android
HW_ACCEL_OVERRIDE Pass aceel options e.g "-accel on" or "-aceel off" optional Android

Kill the container

  • Run the following command to kill and remove the container:

    docker rm -f androidContainer
    

docker-android-emulator's People

Contributors

amrsa1 avatar mohabmohie avatar pnicolassfl avatar nicos44k avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.