I have the following error that pops up when I try to run the emulator:
Emulator: emulator: ERROR: Unknown AVD name [Nexus_5X_API_27], use
-list-avds to see valid list.
Emulator: Process finished with exit code 1
Given that I just created the avd, can you help me understand why it cannot find it and how to solve this problem?
Thanks in advance
Why this happened?
When you try to start the avd, android studio will find the Nexus_5X_API_27.ini
in $ANDROID_SDK_HOME/avd/
. But when you create the avd by android studio, the Nexus_5X_API_27.ini
is been put into $HOME/.android/avd/
. So android studio can not find the ini
file to start the avd.
Resolution
Copy the Nexus_5X_API_27.ini
from $HOME/.android/avd/
to $ANDROID_SDK_HOME/avd/
will solve the problem.
I experienced the same issue, regardless of the AVD. I'm too new to understand why, but it seems that Android Studio created /.android/avd
directories in two locations:
/root/.android/avd
/home/USERNAME/.android/avd
The .avd and .ini created when creating a new AVD were stored in the 1st location, and the 2nd location was empty. To resolve it, I copied and pasted both the .avd and .ini files for each AVD from 1 to 2 (they needed to be in both in order for AS to see and run the AVD). The emulator then ran successfully.
If your Android Studio create AVDs in the ~/.android/avd directory, here are the step by step instructions:
- Open control panel
- Then go to System
- Then go to Change Environment Variables of the User
- Then click create a new environment variables
- Create a new variable named ANDROID_SDK_HOME
- Set its value to your Android directory, like C:/users//.android