반응형

To run an Android emulator from the command line on Windows, you'll need to have Android Studio and the Android SDK installed. Here’s a step-by-step guide:

Step 1: Ensure Android SDK is Installed

  1. Install Android Studio if it's not already installed. This will install the Android SDK as well.
  2. Set up the Android SDK Path:
    • Open Android Studio.
    • Go to File > Settings > Appearance & Behavior > System Settings > Android SDK.
    • Note the path of the Android SDK (e.g., C:\Users\<YourUsername>\AppData\Local\Android\Sdk).

Step 2: Add SDK Tools to System PATH

  1. Add the SDK Tools to the PATH:
    • Press Windows + R, type sysdm.cpl, and hit Enter.
    • Go to the Advanced tab and click on Environment Variables.
    • In the System variables section, find the Path variable and click Edit.
    • Click New and add the following paths:
      C:\Users\<YourUsername>\AppData\Local\Android\Sdk\platform-tools
      C:\Users\<YourUsername>\AppData\Local\Android\Sdk\emulator
    • Replace <YourUsername> with your actual username.

Step 3: List Available Emulators

Open Command Prompt and run the following command to list all available AVDs (Android Virtual Devices):

emulator -list-avds

This will display the names of all the emulators you have configured.

Step 4: Start an Emulator

To start an emulator, use the following command:

emulator -avd <emulator_name>

Replace <emulator_name> with the name of the AVD you want to start, as listed by the emulator -list-avds command.

Example

  1. List available emulators:Output might be:
  2. Pixel_3a_API_30 Nexus_5X_API_29
  3. emulator -list-avds
  4. Start an emulator:
  5. emulator -avd Pixel_3a_API_30

This command will launch the Pixel_3a_API_30 emulator.

Troubleshooting

  • If you get a "command not found" error, ensure that the paths to platform-tools and emulator are correctly added to your system PATH.
  • Make sure the Android emulator is properly configured in Android Studio.

Summary

  1. Install Android Studio and set up the Android SDK.
  2. Add SDK tools to the system PATH.
  3. List available AVDs with emulator -list-avds.
  4. Start an emulator with emulator -avd <emulator_name>.
반응형

+ Recent posts