紧急:AVD系统路径损坏.检查您的ANDROID_SDK_ROOT值 [英] PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value

查看:133
本文介绍了紧急:AVD系统路径损坏.检查您的ANDROID_SDK_ROOT值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在终端中键入cordova run android后,出现此错误:

After typing cordova run android in terminal, I'm getting this error:

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'

在导出之前,我得到了:

Before exporting I got:

Waiting for emulator to start...
PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT

有什么想法我要去哪里吗?我确定这是sdk的根目录,为什么我会损坏avd系统路径?

Any ideas where I'm going wrong? I'm sure this is the sdk root so why am I getting broken avd system path?

推荐答案

将AVD或SDK移至另一个目录,或将旧的SDK替换为新的SDK或以某种方式获取该SDK时,可能会有几个不同的问题损坏.

There are may be several different problems when you move your AVD or SDK to another directory, or replace an old SDK with a new one, or somehow get the SDK corrupted.

下面,我将描述我所知道的所有可能的问题,并为您提供几种解决问题的方法.

Below I'll describe all the possible problems I know, and will give you several ways to solve them.

当然,我假设您已创建任何AVD,并且它位于C:\Users\<user_name>\.android\avd(Windows)或~/.android/avd(Linux/MacOS)中.

Of course I assume that you have any AVD created, and it is located in C:\Users\<user_name>\.android\avd (Windows) or ~/.android/avd (Linux/MacOS).

如果将.android移至另一个位置,则将ANDROID_SDK_HOME环境变量设置为包含.android的父目录的路径,并确保 AVD Manager 成功找到了虚拟设备

If you moved .android to another place then set the ANDROID_SDK_HOME environment variable to the path of the parent dir containing your .android and make sure the AVD Manager successfully found your Virtual Device.

还要检查<user_home>/.android/avd/<avd_name>.ini

Also check paths in <user_home>/.android/avd/<avd_name>.ini


SDK结构不完整/损坏

PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT
PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value

如果仿真器找不到SDK或SDK损坏,则会发生这2个错误.

These 2 errors happen if the emulator cannot find the SDK, or the SDK is broken.

因此,首先我建议完全删除ANDROID_SDK_ROOT变量.仅当仿真器位于SDK目录之外时才需要.但总的来说,您的仿真器位于SDK目录中.并且在这种情况下,它必须自动检测SDK的位置.如果不是,则您的SDK可能具有错误的文件树.请执行以下操作:

So, first of all I recommend to remove the ANDROID_SDK_ROOT variable at all. It's only needed when the emulator is located outside of the SDK directory. But in general, your emulator stays inside the SDK dir. And in this case it must detect the SDK location automatically. If it doesn't, then your SDK probably has wrong filetree. Please do the following:

  1. 检查 SDK目录至少具有以下四个目录:emulatorplatformsplatform-toolssystem-images. 这非常重要!.这些目录必须存在.如果其中一些不存在,则只需创建空目录即可.

  1. Check that the SDK directory has at least these 4 directories: emulator, platforms, platform-tools, system-images. It is very important! These directories must be present. If some of them don't exist, then just create empty dirs.

转到<user_home>/.android/avd/<avd_name>并打开config.ini.找到image.sysdir.1属性.它指向SDK目录内部的目录,该目录包含实际的系统映像.确保此目录存在并且包含build.propsystem.img等文件.如果不存在,则必须打开 SDK Manager 并下载AVD所需的系统映像(请参阅下面).

Go to <user_home>/.android/avd/<avd_name> and open config.ini. Find the image.sysdir.1 property. It points at the directory, inside the SDK directory, that contains the actual system image. Make sure that this directory exists and contains files like build.prop, system.img, etc. If it doesn't, then you have to open the SDK Manager and download system images your AVD requires (see below).

如果一切都设置正确,则必须消除有关ANDROID_SDK_ROOT的这些错误.如果不是,那么现在您可以尝试设置ANDROID_SDK_ROOT变量.

If everything's set up properly, when these errors about ANDROID_SDK_ROOT must be gone. If they're not, then now you may try to set up ANDROID_SDK_ROOT variable.

您可能面临的下一个问题是模拟器开始启动,但是挂断或立即退出.这可能意味着您没有安装所有必需的软件包.

The next problem you may face is that the emulator starts to launch, but hangs up or quits immediatelly. That probably means that you don't have all the required packages installed.

另一个可能的错误是:

无法自动检测到ADB二进制文件.在扩展设置页面中添加自定义ADB路径之前,某些仿真器功能将不起作用.

Could not automatically detect an ADB binary. Some emulator functionality will not work until a custom path to ADB is added in the extended settings page.

因此,要成功启动任何AVD,必须确保至少安装了以下软件包:

So, to successfully launch any AVD you must be sure that at least these packages are installed:

emulator (Android Emulator)
platform-tools (Android SDK Platform-Tools)
tools (Android SDK Tools)

正如我前面提到的,您必须安装您的AVD正在使用的系统映像,例如system-images;android-25;google_apis;x86

And as I mentioned earlier you must install system images your AVD is using, for example system-images;android-25;google_apis;x86

请注意,SDK上的最新版本没有独立的SDK Manager.exe.取而代之的是,您必须使用Android Studio或tools\bin\sdkmanager.bat(Linux/MacOS可能具有sh文件).

Note that the most recent versions on SDK don't have a standalone SDK Manager.exe. Instead of it you have either to use Android Studio, or tools\bin\sdkmanager.bat (Linux/MacOS probably have sh files).

要列出所有可用的软件包,请使用sdkmanager --listsdkmanager --list --verbose

To list all available packages use sdkmanager --list or sdkmanager --list --verbose

要安装软件包,请使用sdkmanager <package1> <package2> ...

To install packages use sdkmanager <package1> <package2> ...

我还建议在您的计算机上安装 HAXM 手动系统.

Also I recommend to install HAXM on your system manually.

当您试图将AVD或SDK从一台计算机或目录移动到另一台计算机或目录时,我会提到的最后一个问题发生了.在这种情况下,您可能会收到这样的错误:

The last problem I'll mention happens when you're trying to move AVD or SDK from one computer or directory to another. In this case you may get such error:

qemu-system-i386.exe:-驱动器if = none,重叠检查= none,cache =不安全,index = 0,id = system,file = C:\Users\<old_user_name>\.android\avd\<avd_name>.

avd \ system.img.qcow2,只读:无法打开后备文件:无法打开'<old_sdk_dir>\system-images\android-22\google_apis\x86\system.img':无效的参数

avd\system.img.qcow2,read-only: Could not open backing file: Could not open '<old_sdk_dir>\system-images\android-22\google_apis\x86\system.img': Invalid argument

有2种解决方法:

  1. 如果您不关心AVD包含的数据,只需从AVD目录中删除所有qcow2文件(例如,从<user_home>/.android/avd/<avd_name>中删除).在这种情况下,您将获得干净版本的Android,例如经过硬重置之后.

  1. If you don't care about the data the AVD contains, just delete all the qcow2 files from the AVD directory (e.g. from <user_home>/.android/avd/<avd_name>). In this case you will get a clean version of Android, like after a hard reset.

如果仿真器上的数据对您很重要,请使用任何十六进制编辑器一一打开所有qcow2文件(我更喜欢

If the data on the emulator is important to you, then open all qcow2 files one by one using any HEX editor (I prefer HxD), find the path of a base img file, and change it to the correct one in the Overwrite mode (to preserve the file size). Then select the path and get its length in hex (e.g. 2F). 2F represents the ASCII slash /. Put it into position 13:

PS:不确定,但是可能有一些实用程序,例如 qemu-img 允许设置不同的基本图像.好吧,对我来说,手动编辑二进制文件会更容易.

PS: Not sure, but there are probably some utilites like qemu-img allowing to set different base image. Well, to me it's easier to manually edit the binary.

现在,您可能将能够成功启动Android虚拟设备.我希望如此:)

Now you'll probably be able to successfully launch your Android Virtual Device. I hope so :)

这篇关于紧急:AVD系统路径损坏.检查您的ANDROID_SDK_ROOT值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆