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


当前回答

/usr/local/share/android-sdk缺少平台目录。 我创建了一个名为平台的空目录来解决这个问题。

其他回答

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

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

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

误差实际上是不同的。使用-verbose选项运行./emulator很有帮助,因为它会显示实际的错误。

检查您的AVD使用的系统镜像是否已经在$ANDROID_SDK_ROOT/system-images/下下载

我有同样的问题后,设置以下路径变量消失了 注意: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,你不需要任何其他的环境变量。