I’m starting to learn Ionic and after a few hours of installing/updating software I went down the short list of commands to see an app on my device. The final command to start an Android emulator, which is:

$ ionic emulate android

Produced this error:

$ ionic emulate android
 
PANIC: Cannot find
AVD system path. Please define ANDROID_SDK_ROOT

Given the error message we of course need to create a new environment variable but instead of creating “ANDROID_SDK_Root” you instead create one called “ANDROID_AVD_HOME”. Along with creating that new variable we will also need to determine the “AVD system path”.

You will be interested to know that Android searches for the AVD path via three different environment variables in a specific order. The variable names and order of precedence are:

  1. $ANDROID_AVD_HOME
  2. $ANDROID_SDK_HOME\.android\avd\
  3. $HOME\.android\avd\

As you can see, “ANDROID_AVD_HOME” trumps the other paths for specifying where your AVD’s can be found.

Creating environment variables in Windows is well documented everywhere you look, but here’s the short list of steps:

  1. Right-click “My Computer”
  2. Click on “Properties”
  3. Click “Advanced System Settings”
  4. Click “Environment Variables”
  5. Under “System Variables” click “New”
    • For the variable name follow the console output and use “ANDROID_AVD_HOME”
    • For the variable value….. see below

Locating the path to your AVD’s can easily be found by firing up the Android Virtual Device Manager which is located in your Android SDK directory. The path to my Android installation was the following:

C:\Users\Rick\AppData\Local\Android\sdk

Yours may be similar to the above, or use Cortana to locate it for you.

Again, locate and start the Android Virtual Device Manager. In this screen shot I’ve created a single AVD:

avd_manager_01

Click an AVD to select it then click on the “Details” button. You will see the following:

avd_manager_02

Note the path to your AVD directory, that is your AVD System Path. Use the path up to the “avd” directory as the value for the variable value as can be seen below:

avd_manager_03

[EDIT] the trailing slash in your paths is important!!! its not in the screen cap, but you must have a trailing slash!!!!

All done. Restart your console and give it a try.