在终端中输入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 OS X上,我也遇到了同样的问题。我无法从Visual Studio中启动Xamarin应用程序,但Android Studio中的原生Java Android项目在虚拟设备中可以运行。

我所做的是:

取消设置ANDROID_HOME和ANDROID_SDK_ROOT环境变量。

unset ANDROID_HOME
unset ANDROID_SDK_ROOT

移除已经崩溃的虚拟设备。我是在Visual Studio中完成的。 创建新的虚拟设备。

其他回答

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

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

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

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

奥列格·切尔的回答让我找到了解决办法。正如他提到的

去/。Android /avd/打开config.ini。找到>image.sysdir。1房地产。它指向SDK中包含系统>图像的目录。确保该目录存在并包含build等文件。道具>系统。img等等。如果它没有,那么你必须打开SDK管理器和>下载系统图像你的AVD需要(见下文)。

我在avd目录中找到了相应的模拟器*.ini文件。 在那里,我修改了“image.sysdir”。1”条目。我将相对路径替换为绝对路径(在前面附加ANDROID_SDK_ROOT)。在此之后,模拟器如预期的那样从命令行启动。

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

我用的是Windows 10,问题是我电脑中的avd目录中有非ascii字符。

下面是该怎么做:

以管理员身份运行cmd

执行如下命令:

mklink /D C:\\.android C:\\Users\\-yourUsername-\\.android

(这将在非ascii字符的路径和新路径之间创建一个符号链接)

在环境变量中添加值为C的ANDROID_AVD_HOME变量:\\.android\avd。