Running emulators
Now that everything is done, we can start with running an emulator
- Run the following command in a terminal to install the necessary packages for the emulator:
sdkmanager "build-tools;32.0.0-rc1" "cmdline-tools;latest" "emulator" "patcher;v4" "platform-tools" - Once, that's done, you can start with downloading an Android version and downloading the packages.
Runsdkmanager --listto get a list of all available packages.
You needplatforms;android-*andsystem-images;android-*;google_apis;x86_64(orsystem-images;android-*;google_apis_playstore;x86_64) where*means the Android API level.
For example, I want to run the latest Android 12L on my emulator, I'll download the Android SDK Platform for it and its system image:
sdkmanager "platforms;android-Sv2" "system-images;android-Sv2;google_apis_playstore;x86_64" - Now that you have all the packages, we can finally create the emulator/virtual device:
avdmanager create avd -n NAME_OF_EMULATOR -k "system-images;android-*;google_apis;x86_64"where
*means the Android API level.
For example:avdmanager create avd -n A12 -k "system-images;android-Sv2;google_apis_playstore;x86_64"
Bonus: You can also use the-dflag to specify a device to get device-specific settings. Available devices can be seen by using theavdmanager list devicescommand - Once the emulator is created, you can launch the emulator by using
emulator -avd NAME_OF_EMULATOR
I hope you learned something new today and this was helpful to you.
If you want to learn more about the Android command line tools, check this link out: https://developer.android.com/studio/command-line/
Cheers!
5
