在终端中输入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系统路径?


当前回答

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

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

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

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

其他回答

修复用户包含非ascii字符的问题

对于“PANIC: AVD系统路径损坏”的人。检查你的ANDROID_SDK_ROOT",原因可能是你的用户在users中包含非ascii字符。

因此,SDK和。android文件夹和AVD文件夹都需要移动到另一个文件夹。

修改SDK路径:

打开Android Studio,进入配置,选择SDK管理器。将当前Android SDK位置更改为例如“C:\Android\ SDK”(或其他地方,只是不在包含非ascii字符的用户文件夹中)。

添加如下系统变量:

ANDROID_SDK_ROOT C:\Android\Sdk
ANDROID_HOME C:\Android\Sdk

更改AVD路径:

要更改AVD文件夹的位置(通常放置在“C:\Users\<用户名>\.android\ AVD”中),您需要更改.android的位置。首先关闭Android Studio,然后添加系统变量ANDROID_SDK_HOME和你想要的。Android的新位置的路径,例如在另一个例子中使用的C:\ ANDROID_SDK_HOME:

ANDROID_SDK_HOME C:\Android_SDK_HOME

添加后,运行Android Studio。然后再关上。现在应该出现了一个名为.android的文件夹。

你需要做的下一件也是最后一件事是设置ANDROID_AVD_HOME系统变量。在本例中,它将在C:\Android_SDK_HOME\.android\avd中

ANDROID_AVD_HOME C:\Android_SDK_HOME\.android\avd

我希望这能解决一些问题。:)

我有同样的问题后,设置以下路径变量消失了 注意:AVD主路径与其他三个不同。

好的,我可以从cordova运行android,我把ANDROID_HOME改为,

export ANDROID_HOME=/usr/local/opt/android-sdk

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

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,你不需要任何其他的环境变量。

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

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

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

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