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

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

我在mac os上运行模拟器时也有类似的问题。经过大量的斗争,我发现我在.bash_profile中设置了错误的sdk路径。我安装了两次android,它导致了这个问题。我设法修复通过匹配ANDROID_SDK_ROOT路径在.bash_profile与sdk,我在android工作室内使用。

这将解决你在macOS中的问题:

pico ~/.bash_profile

export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export ANDROID_SDK_HOME=/Users/$USER/Library/Android/sdk
export ANDROID_AVD_HOME=/Users/$USER/.android/avd
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_AVD_HOME

source ~/.bash_profile

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

今天刚刚遇到了这个问题,并设法解决了它。

模拟器:[140735565005632]:ERROR:android/android-emu/android/qt/qt_setup.cpp:28: qt library not found at /Users/your_user_name/ library /android/ sdk/ Emulator /lib64/qt/lib

15:08 Emulator: Could not launch '/Users/your_user_name/Library/Android/sdk/ Emulator /qemu/darwin-x86_64/qemu-system-x86_64':没有这样的文件或目录

解决方法非常简单。通过Android Studio => tools => Android => SDK manager => SDK tools => select Android emulator => Apply

我使用的是macOS High Sierra的MacBook Pro,我相信你的机器与此问题无关。在第一次使用Android Studio 3.0.1运行Android Studio安装管理器时,模拟器没有明显安装,至少对我来说是这样

同时,确保你在.bashrc或.zshrc中定义了你的路径,就像这样:

export ANDROID_HOME=/Users/your_user_name/Library/Android/sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools