Setting Up an Android Emulator in Android Studio

Kelsey Nocek
4 min readSep 25, 2023

--

Do you ever go to start a project where you need an Android Emulator, but when you go to start your project and type “a” to open your emulator, you get a CommandError code that says “No Android connected device found, and no emulators could be started automatically”. I am going to share how to set up an Emulator. The official docs are a great resource and this is where I am getting my information from.

Step 1:
Open Android Studio and click on “more actions”. In the dropdown menu, click on “Virtual Device Manager”.

The Device Manager will open and you want to click on “Create Device” in the top left corner:

It’s recommended that you create an AVD for each system image, but for simplicities purpose, we are just going to create one. (However if you want to learn more about AVD’s, check out the official docs. It will go more in depth on creating AVD’s.) Click on “Pixel XL” or any other phone name that suits what you need and then click “Next”.

Next, select a hardware profile. In this case, I am going to select “API 34” and then click “Next”.

The Verify Configuration window appears. Change the AVD properties as you need and click “Finish”.

Great! You have a device created.

After you have created a device, open Android Studio, go to Settings > Languages & Frameworks > Android SDK. From the SDK Platforms tab, select the latest Android version (API level).

Currently you are on the page of “SDK Platforms”, click next to it where it says “SDK Tools” and make sure that you have at least one version of the Android SDK Build-Tools and Android Emulator installed.

Copy or remember the path in the box that says Android SDK Location. Mine is crossed out above. Click “OK”.

Next, you want to set up an environmental variable pointing to the Android SDK location.

This will either be your /.zprofile or ~/.zshrc (if you are using bash, then ~/.bash_profile or ~/.bashrc). Add the following lines of code to your config file:

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools

If you don’t know how to edit your config files, below is an example if you are using Zsh. If you are using bash, google how to edit your config file and you can easily find how to do so. It’s very similar to the explanation below.

  1. Open your terminal window
  2. Use a text editor like nano, vim, gedit, or code (Visual Studio Code) to open ~/.zshrc. In this case I am going to use “nano”. If the file doesn’t exist yet, it will be created.
nano ~/.zshrc

3. Add the lines of code you want to include in your ~/.zshrc. For Android SDK environment variables and PATH modification, use something like this:

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools

Adjust the first path accordingly to match your Android SDK installation location. (This is the path I had you copy or memorize before. If you can’t remember, open up your Android Studio settings and it will be there.)

The 2nd (emulator) and 3rd (platform-tools) path can stay the same.

I also personally like to add a comment above these Paths stating what they are:

# Path to Android SDK installation location
..paths here

You can exit out of your Config file by using Ctrl+X ( if on a mac).

It will ask you if you want to save and what file name you want to write it to. You can say “yes” and hit “enter” to save the file you are writing in.

Next you will want to reload the path environment variables in your current shell:

#for bash
source $HOME/.bashrc

#for zsh
source $HOME/.zshrc

annnnnnd BADAH BOOM BADAH BAM!

Hopefully that was helpful. Again, check out the docs for more details. :)

Oh and make sure to restart your text editor (for me it’s VsCode)

--

--

Kelsey Nocek

🌱 Currently learning ReactNative 😄 2023 goals: Keep learning! ⚡ Fun fact: I love to play music and be outside