Skip to content

Android Studio Meerkat and Emulator in Docker

Virtual desktop requirements:

  • Nested virtualization must be enabled:

  • Minimum features of the virtual desktop (can be adjusted to your preference):

Installation

Download link for the Meerkat version (used in this guide): android-studio-2024.3.1.13-linux.tar.gz

Open Firefox, paste the link, and the compressed .tar.gz folder containing Android Studio in the Meerkat version will be downloaded.

sudo apt update
sudo apt -y upgrade

cd Downloads
tar -xzvf android-studio-2024.3.1.13-linux.tar.gz

cd android-studio/bin
./studio.sh

  • Accept the policies and terms:

  • And we can begin the installation by clicking the Finish button:

This screen will appear with the option to create a new project or load an existing one:

To demonstrate how it works, we will create a new project from a template provided by the program called "Bottom Navigation Views Activity", select it and click Next:

We name the project Isard App 1, and the package name as com.isard.isardapp1

The first time we load our application, it will take longer because it needs to download all the packages and dependencies. Future loads won't take as long.

We can view the main code:

And the layout, which shows the visual result of the app:

Once the program is installed and the project is created, we exit Android Studio.

Emulator

To achieve smoother and faster performance, we run the emulator inside a container.

  • Install Docker:
    sudo apt update
    sudo apt-get remove docker docker-engine docker.io containerd runc curl
    sudo apt-get update
    sudo apt-get install -y \
        ca-certificates \
        curl \
        gnupg \
        lsb-release
    sudo mkdir -m 0755 -p /etc/apt/keyrings
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
    echo \
      "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
      $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    sudo apt-get update
    sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    sudo systemctl status docker
    

Depending on what we want to do, the command to execute may change. In this demo, we use version 14.0 of the emulator, and the device "Samsung Galaxy S10". To save the emulator state, we mount a volume.

We create a script that will launch the emulator in the Firefox browser each time it is run (you can change it to your preferred browser):

sudo nano emulator_Samsung-Galaxy-S10.sh
sudo docker run --rm -d -p 6080:6080 -p 5555:5555 -p 5554:5554 -e EMULATOR_DEVICE="Samsung Galaxy S10" -e WEB_VNC=true --device /dev/kvm --name android-container -v root:/root -v data:/home/androidusr budtmo/docker-android:emulator_14.0

firefox http://localhost:6080

Useful Links:

In this GitHub project, we can find the Docker image to launch the emulator: https://github.com/budtmo/docker-android

Emulator versions: https://github.com/budtmo/docker-android?tab=readme-ov-file#list-of-devices

And the following list of devices that can be launched: https://github.com/budtmo/docker-android?tab=readme-ov-file#list-of-devices


Usage

The first time we open the emulator it’s normal for it to take longer. However, the next times, the saved state will prevent restarting the whole process, and we can run our app directly.

To run an Android Studio app in the emulator, follow these steps:

  1. Start the emulator by running the script we created:

    bash ./emulator_Samsung-Galaxy-S10.sh
    
  2. Open Android Studio. Either from the program launcher or by running ./studio.sh from the /path/to/download/android-studio/bin folder.

  3. Inside our project, on the right-hand side, there is a "Device Manager" section where the device launched in the container should appear:

  4. Make any desired changes to the application, and run it using the 'Run' button:

Now the app should appear inside the emulator.

When you're done and want to shut down the emulator, follow these steps:

  1. Click the X on the right-hand side of the emulator interface:

    A message will appear indicating the emulator state is being saved:

  2. Remove the container:

sudo docker rm -f android-container

Next time you want to start the emulator again, repeat the same process. The emulator will launch with the saved state, even if the virtual desktop was restarted.


Last update: March 27, 2025