在终端中输入cordova运行android后,我得到了这个错误:

Waiting for emulator to start...
PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [/Users/username/Library/Android/sdk]!

这发生在导出之后:

export ANDROID_SDK_ROOT='/Users/username/Library/Android/sdk'

在导出之前,我得到:

Waiting for emulator to start...
PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT

你知道我哪里错了吗?我确定这是sdk根,所以为什么我得到破碎的avd系统路径?


当前回答

要修复或避免此问题,请确保:

You have an environment variable ANDROID_SDK_ROOT pointing to a root folder of android sdk. You have a correct file structure in the sdk folder. cmdline-tools, emulator, platform-tools, system-images, platforms should be present. If you don't have these folders you should install missing components. emulator is the emulator itself. system-images has iso images of OS to run in the emulator. platforms has platform packages required to compile an app for different APIs. platform-tools has adb and other necessary tools. Without these components the emulator wont start and will post the same error about broken avd path. Make sure that you downloaded through sdkmanager matching api versions of system image and platform. e.g. for API-30 platforms;android-30 and system-images;android-30;default;x86_64. Make sure that your avd devices are located in HOME/.android/avd. If you have custom location for avd devices you should create one more environment variable ANDROID_AVD_HOME pointing to /avd/ folder.

本文提供了所有环境变量的信息,但除了ANDROID_SDK_ROOT和ANDROID_AVD_HOME,你不需要任何其他的环境变量。

其他回答

ANDROID_SDK_HOME是指向根目录的指针。该文件默认创建在“C:\Users\name\. android”目录下。android”,而不是你的SDK文件夹的根目录。然后: —将ANDROID_SDK_HOME分配到SDK根文件夹将无效。 -如果你的路”。“android”文件有非ascii字符,它将无法工作。 - AVD文件夹必须在您当前的”。android”文件。

所以答案是:

Change your SDK folder, if you need, like the previous answers (inside the project on Android Studio). Close Android Studio. Control Panel > System > Advanced System Settings > Environment Variables. Add a new User variable: Variable Name: ANDROID_SDK_HOME Variable Value: C:\src (or any folder that has not problems with non-ASCII characters or S.O. privileges) THE PATH THAT YOU WILL ENTER CANNOT BE ROOT FOLDER OF YOUR ANDROID SDK!!! Open Android Studio. Make sure a folder called ".android" was created in your new location. Delete the Android Virtual Device (AVD) that you created. Close and open Android Studio. Create a new AVD and see the magic happens.

欢呼。

你应该添加AVD模拟器。 去这个位置:

C:\Users\%username%\AppData\Local\Android\sdk\

启动AVD管理器,在第二个选项卡(设备定义)中单击“创建AVD”按钮。

按照下面的步骤,这将解决您的问题

1.

export ANDROID_HOME=/usr/local/Cellar/android-sdk/24.4.1
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME/bin

2.

Go to android studio preferences => Build, Execution, Deployment => Build Tools => Gradle => Android studio  => Enable embedded Maven Repository should be selected.

3.

Go to android studio preferences => Appearance & Behavior => System Settings => Android SDK => Go to SDK Tools and select Android Emulator

在尝试了一段时间的其他谷歌“解决方案”后,唯一对我有用的是,在Windows上设置ANDROID_SDK_ROOT环境变量,并添加和删除ANDROID_HOME和ANDROID_SDK_HOME变量后,是Xerox23的答案-编辑AVD的config.ini将ANDROID_SDK_ROOT的值硬编码到image.sysdir中。1房地产。

这是使用Android Studio 3.0.1和模拟器26.1.4,从Android Studio内的AVD管理器启动虚拟设备。

这意味着您使用工具的路径不正确。这是它在mac上使用brew的样子。注意版本。

export ANDROID_SDK_ROOT='/usr/local/Cellar/android-sdk/24.4.1_1'

在你的情况下,看起来你应该运行这个:

export ANDROID_SDK_ROOT='/Users/username/Library/Android/sdk'