在终端中输入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/avd文件夹中的图像模拟器,在我安装lib32stdc++6后:

sudo apt-get install lib32stdc++6

所以,它起作用了!魔法吗?

其他回答

删除使用Homebrew Android SDK作为默认SDK时的错误

和@ freak一样,我用homebrew (mac的包管理器)安装了android-sdk。我需要执行下面的操作来修复这个错误,因为我在遵循nativescript教程时遇到了这个错误。如果你像我一样打算使用android-sdk版本的brew版本使用这个答案(这将允许你使用nativescripts tns运行android api),如果你想要android工作室默认的android-sdk遵循@ freak的答案。

配置Android Studio以使用Homebrew的Android SDK

基本上你只需要在Android studio中更改Android SDK的位置。首先在android studio中打开一个项目。然后点击这个按钮打开SDK管理器。

接下来,当android SDK管理器的默认首选项出现时,你需要单击android SDK位置旁边的编辑。

查找Homebrew的Android SDK的位置

接下来,你需要在sdk组件设置屏幕上更新sdk位置,我的brew android-sdk位于这里/usr/local/share/android-sdk。你可以通过运行brew cask info android-sdk来找到你的安装位置,然后在输出的底部应该说:

You can control android sdk packages via the sdkmanager command.
You may want to add to your profile:

  'export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"'

导出的ANDROID_SDK_ROOT变量的值(这里是/usr/local/share/android-sdk)是自制的android sdk的位置。

然后点击“Android SDK Location”按钮(图中标记为1),粘贴Homebrew的Android SDK位置。

然后通过安装任何包来完成向导。在这一步中,我需要删除并重新创建我的设备模拟器,但在那之后,它似乎工作得很好。

设置Android SDK环境变量指向Homebrew的Android SDK

Also you may want to make sure if you are going the Homebrew route that your profile settings script has the ANDROID_HOME and ANDROID_SDK_ROOT environment variables set to your Homebrew location of the android sdk otherwise the above won't work yet. This can get changed from the Homebrew location if you installed Homebrew before installing Android Studio as pointed out in this answer by @Jamie Armour. You can check the environment variables for the android sdk are set correctly by running echo $ANDROID_HOME and echo $ANDROID_SDK_ROOT and verifying that they both show the Homebrew location of the android sdk.

如果你需要更改ANDROID_HOME和ANDROID_SDK_ROOT值,你可以在Mac的配置文件设置中这样做,可能在~/中。~ / bash_profile。”Bashrc”,或者“~/”。并定义如下:

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

You need to change the values of both the exports to the proper values of Homebrew's android SDK location then save the file. To verify that the right values have been written you should first either close and open your terminal which should rerun the file and reset the environment variables or you can source the file by running source <profile file name> where is the profile file you edited and saved. You then can rerun echo $ANDROID_HOME and echo $ANDROID_SDK_ROOT to verify that they have the Homebrew android sdk location.

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.

欢呼。

我的Windows10也有同样的问题, 通过以下步骤解决了我的问题。 开放Android Studio -工具 - SDK管理器 -复制Android SDK位置 Android SDK 设置系统环境变量 ANDROID_HOME和ANDROID_SDK_ROOT 系统环境变量

在Windows 10(没有Android Studio)中,我通过传输“PANIC: Broken AVD系统路径”解决了这个问题。android的文件夹从默认位置“C:\Users\Леон”进入SDK文件夹。改变环境

ANDROID_SDK_ROOT=D:\Android\SDK
ANDROID_AVD_HOME=%ANDROID_SDK_ROOT%\.android\avd
ANDROID_EMULATOR_HOME=%ANDROID_SDK_ROOT%\.android   

我认为问题可能是在USER路径中的非ascii符号中,或者它们需要“全部放在一起”。

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变量包含正确的路径应该会让模拟器启动。