The procedure is as follows:
- Install Sdkmanager either via pip or the Linux package manager.
- Run the command
sudo mkdir /opt/android-sdk/
to make the Directory where the Android emulator folders will be stored. - Run the command
sudo chown $USER /opt/android-sdk
to make the folder and path accessible without using sudo permissions. - To install the emulator, execute
sdkmanager 'emulator'
from the terminal. - Install latest cmdline tools using
sdkmanager "cmdline-tools;latest"
command. - Add ANDROID_HOME (also ANDROID_SDK_ROOT) to path, if you've installed on path other than /opt/android-sdk.
- Install sdkmanager platform for android 31 using
sdkmanager "platforms;android-31"
- Create an Android Virtual Device (AVD) with the command
/opt/android-sdk/cmdline-tools/latest/bin/avdmanager create avd --name "Some_preffered_name" --tag default --package "system-images;android-31;default;x86_64" --sdcard 64M --device "Nexus 5"
Please note that "Some_preffered_name" is a substitute for a name you would like to use.E.g Nexus_5_API_31 - To start the emulator, run
/opt/android-sdk/emulator/emulator @Some_preffered_name
and you are all set.