Downloading and installing the android emulators is a big headache as we have to download and set up tons of stuff manually like, JAVA, ANDROID TOOLS, etc. To avoid these manual steps there is a new technology that will solve your problem and rescue you from it.
A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries, and settings.
It used to be that when you wanted to run a web application, you bought a server, installed Linux, set up a LAMP stack, and ran the app. If your app got popular, you practiced good load balancing by setting up a second server to ensure the application wouldn't crash from too much traffic.
So by reading these 2 paragraphs you would become familiar with the words containers and docker right?
Now to run a container you first need a Docker Image, A docker image is just a file in which steps are written in it one by one and when we try to execute those steps it all executes in an isolated environment and becomes a container.
Google has an official Docker Script to run Android Emulators, so you don't need to write the images from scratch all by yourselves.
Well yeah, I said you don't need to install any software, but you should at least have Docker and ADB installed for once. Docker for running images and ADB for detecting virtual devices by which you can use that emulator on your host device or can also access it remotely.
Open a terminal and paste these codes.
docker run
-e ADBKEY="$(cat ~/.android/adbkey)"
--device /dev/kvm
--publish 8554:8554/tcp
--publish 5555:5555/tcp
us-docker.pkg.dev/android-emulator-268719/images/30-google-x64:30.1.2
This will download the image and run it, you will not need to do any further steps.
After the container is ready, you can connect to your device just by typing this to terminal
adb connect localhost:5555
After it you can see the available devices through ‘ADB Devices’ command
Running an emulator on Linux has become easy as you just need to execute a simple one line of code and your device will automatically start the emulator. But keep in mind that this tutorial will only work on Linux devices in which KVM is enabled. In windows PC it won't work as no Nested KVM is available in it. Thank You!