Why the emulator does not start in Android Studio?

Sometimes for any reason the emulator in Android Studio does not start correctly. Perhaps because I upgraded the IDE Android Studio or because I do not have SDK installed correctly. Whatever the reason, I recommend the following two simple validations:

1. Try to launch the emulator by command line with Android Studio. If there is any error, you catch it!


In this case, I use emulator -list-avds to list my virtual devices created. Then I try to launch my emulator with emulator -avd Nexus_5_API_24. If anything is going wrong, I'll see the problem listed on the terminal.

For example:


This means that I don't have setup the SDK path correctly in my machine. To resolve it, I will need to add my SDK location in the path as I show you in the next validation.

2. Check to have the SDK in the PATH.

You can see where is installed the SDK in Android Studio -> Preferences -> Appearance & Behavior -> Android SDK  over the box: Android SDK Location


Then, add ANDROID_SDK_ROOT and ANDROID_HOME variables to path. In Mac, you will need to execute the next commands in the terminal to add your SDK in the PATH

export ANDROID_SDK_ROOT=/Users/$USER/Library/Android/sdk
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

If ANDROID_HOME is defined and contains a valid SDK installation, it's value is used instead of the value in ANDROID_SDK_ROOT. However, I recommend define both of them.


Extra Tip:

If you are emulating with Genymotion to preven conflicts between Genymotion's ADB and SDK's ADB because both of them use the same port, I recommend always set up ADB Genymotion to use the ADB SDK, in that way you can avoid issues of incompatible (i.e. ddms: 'adb.exe,start-server' failed — run manually if necessary, Android Studio).



Previous
Next Post »
Thanks for your comment