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


当前回答

如果你仍然需要一个答案,那么在我的情况下,它在(重新)下载Android图像后工作,但直接从Android Studio,而不是通过Visual Studio按钮。

其他回答

删除早期创建的设备。 关闭Android工作室。 打开:控制面板->系统和安全->系统->高级系统设置-> 环境变量。 创建新变量ANDROID_SDK_HOME并设置 新路径(在我的情况下,它是F:\Coding2019\Android\AVDdevices)。推动“ok”。 打开Android Studio。 创建新设备。在下拉菜单中创建完成后,点击“查看详细信息”可以看到新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_SDK_HOME是指向根目录的指针。该文件默认创建在“C:\Users\name\. android”目录下。android”,而不是你的SDK文件夹的根目录。然后: —将ANDROID_SDK_HOME分配到SDK根文件夹将无效。 -如果你的路”。“android”文件有非ascii字符,它将无法工作。 - AVD文件夹必须在您当前的”。android”文件。

所以答案是:

Change your SDK folder, if you need, like the previous answers (inside the project on Android Studio). Close Android Studio. Control Panel > System > Advanced System Settings > Environment Variables. Add a new User variable: Variable Name: ANDROID_SDK_HOME Variable Value: C:\src (or any folder that has not problems with non-ASCII characters or S.O. privileges) THE PATH THAT YOU WILL ENTER CANNOT BE ROOT FOLDER OF YOUR ANDROID SDK!!! Open Android Studio. Make sure a folder called ".android" was created in your new location. Delete the Android Virtual Device (AVD) that you created. Close and open Android Studio. Create a new AVD and see the magic happens.

欢呼。

NativeScript

对于任何通过NativeScript启动android模拟器遇到麻烦的人来说,它可能是env vars ANDROID_HOME和ANDROID_SDK_ROOT已被覆盖。

我是如何给自己制造一个问题的,那就是安装Android Studio来生成一个不同的模拟器。我这样做是在我已经通过home brew安装了android sdk之后。

因此,如果在NativeScript安装期间,您选择通过HomeBrew安装android sdk, NativeScript将设置如下:

ANDROID_HOME=/usr/local/share/android-sdk
ANDROID_SDK_ROOT=/usr/local/share/android-sdk

随后安装Android Studio将覆盖这些值:

ANDROID_HOME=/Users/[User]/Library/Android/sdk
ANDROID_SDK_ROOT=/Users/[User]/Library/Android/sdk

因此,Android studio和Android sdk的NativeScript/Brew安装自然存在冲突。删除其中一个和/或验证env变量包含正确的路径应该会让模拟器启动。

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

Goto工具> SDK管理器然后

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

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

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

ANDROID_HOME ANDROID_SDK_ROOT

环境变量