在终端中输入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,你不需要任何其他的环境变量。

其他回答

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

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

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

中国的小伙伴注意!原因是avd目录不能包含中文 上面这些方法我都试过了,还是报错,不知道是不是我的avd目录里有汉字。所以我改变默认的avd目录通过以下步骤,它工作。 1. 创建一个路径不包含非ascii字符的文件夹 2. 复制或剪切默认的avd文件夹$HOME/。Android在你刚刚创建的文件夹下面 3.添加PATH ADNDROID_SDK_HOME, Android工作室会在$ADNDROID_SDK_HOME/.android/avd下面找到avd

终于成功了!:>

打开你的android studio,然后关注工具栏。

Goto工具> SDK管理器然后

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

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

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

ANDROID_HOME ANDROID_SDK_ROOT

环境变量

在Mac OS X上,我也遇到了同样的问题。我无法从Visual Studio中启动Xamarin应用程序,但Android Studio中的原生Java Android项目在虚拟设备中可以运行。

我所做的是:

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

unset ANDROID_HOME
unset ANDROID_SDK_ROOT

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

删除早期创建的设备。 关闭Android工作室。 打开:控制面板->系统和安全->系统->高级系统设置-> 环境变量。 创建新变量ANDROID_SDK_HOME并设置 新路径(在我的情况下,它是F:\Coding2019\Android\AVDdevices)。推动“ok”。 打开Android Studio。 创建新设备。在下拉菜单中创建完成后,点击“查看详细信息”可以看到新AVD的新路径。