Process finished with exit code 1 : Unknown AVD name

霸气de小男生 提交于 2019-12-08 17:05:25

问题


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


回答1:


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:

  1. /root/.android/avd
  2. /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.




回答2:


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.




回答3:


For windows users, see the ANDROID_SDK_HOME path,then check the ANDROID_SDK_HOME/avd/,is there that Emulator(you just created) existed?If there's not existed,then copy the emulator.avd and emulator.ini files in ANDROID_SDK_HOME/.android/avd/ to ANDROID_SDK_HOME/avd/, finally it did worked!




回答4:


Deleting C:\Android\android-sdk and reinstalling android studio fixed this for me.




回答5:


There are actually several environment variables that you can set:

  • ANDROID_SDK_HOME
  • ANDROID_EMULATOR_HOME (default is $ANDROID_SDK_HOME/.android/)
  • ANDROID_AVD_HOME (default is $ANDROID_EMULATOR_HOME/avd/)

See https://developer.android.com/studio/command-line/variables

The default location of the Android SDK is your home directory, which depends on your operating system. For instance, on Windows it's C:\Users\*Owner*\AppData\Local\Android\Sdk.

If you have moved your home directory to a different disc, you can use the environment variables mentioned above to adjust the paths on a as-needed basis.




回答6:


When you create the AVD with Android Studio it's created in root location but our Android SDk location is set on somewhere in HOME. So you just need to move your avd folder from root location to home location path.

Root location path:

/root/.android/avd

Home location path:

/home/USERNAME/.android/avd

You don't need to keep avd folder on both the location because whenever you run your app on avd from Android Studio it's always looking it on HOME location.




回答7:


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


来源:https://stackoverflow.com/questions/48996437/process-finished-with-exit-code-1-unknown-avd-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!