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

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

其他回答

我通过删除文件/usr/local/share/android-sdk解决了这个问题, 因为这个文件是我用自制软件创建的。

export ANDROID_HOME=/Users/<username>/Library/Android/sdk

export ANDROID_SDK_ROOT=/Users/<username>/Library/Android/sdk

export ANDROID_AVD_HOME=/Users/<username>/.android/avd

够了....

我遇到了这个问题,因为我从早期就开始使用React Native。谷歌已经弃用命令行工具,坚持使用Android studio。我的解决方案是删除命令行工具

rm -rf /usr/local/Cellar/android-sdk

rm /usr/local/bin/android

按照指示打开AS安装sdk v6 https://facebook.github.io/react-native/docs/getting-started.html#1-install-android-studio

制作一个新的AVD,它将毫无错误地启动

/usr/local/share/android-sdk缺少平台目录。 我创建了一个名为平台的空目录来解决这个问题。

删除使用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.

这意味着您使用工具的路径不正确。这是它在mac上使用brew的样子。注意版本。

export ANDROID_SDK_ROOT='/usr/local/Cellar/android-sdk/24.4.1_1'

在你的情况下,看起来你应该运行这个:

export ANDROID_SDK_ROOT='/Users/username/Library/Android/sdk'