Running emulators

Now that everything is done, we can start with running an emulator

  1. 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"


  2. Once, that's done, you can start with downloading an Android version and downloading the packages.
    Run sdkmanager --list to get a list of all available packages.

    You need platforms;android-* and system-images;android-*;google_apis;x86_64 (or system-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"


  3. 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 -d flag to specify a device to get device-specific settings. Available devices can be seen by using the avdmanager list devices command

  4. 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!
Discussion
Good one @daksh777

2

5

1