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


当前回答

为了解决这个问题,我必须使用SDK Manager.exe(在“C:\Program Files (x86)\Android\ Android - SDK”中)安装缺少系统映像的包。我注意到我需要的系统映像(“Android -23”)在“C:\Program Files (x86)\Android\ Android -sdk\system-images”中丢失了。

在运行SDK Manager.exe并安装适当的包后,我可以在Android Studio中运行模拟器。

以下是对我有效的解决方案:

https://www.embarcadero.com/starthere/xe5/mobdevsetup/android/en/creating_an_android_emulator.html

其他回答

在Mac: 我使用brew和Android Studio安装了Android -sdk。不知何故,两次安装导致了这个问题。当我卸载我的brew安装的sdk使用brew桶卸载android-sdk,并添加以下vars到我的env。它工作。

export ANDROID_HOME=/Users/<Username>/Library/Android/sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME

对于windows机器:在尝试了大量的设置路径,删除路径等。 最后的工作是找到文件夹c:\ users \johndo \。然后删除它。之后你就可以使用Android Studio了,它会要求你下载并安装一个新的AVD,它会覆盖并创建一个新的文件夹和文件。这就解决了问题。

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

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

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 studio,然后关注工具栏。

Goto工具> SDK管理器然后

外观和行为>系统设置> Android SDK

现在在选项卡中从这里复制Android SDK位置 Android SDK

然后去你的环境变量,然后设置路径与这些变量

ANDROID_HOME ANDROID_SDK_ROOT

环境变量