无法在Android Studio中运行模拟器

时间:2021-07-10 15:19:09

I just got done installing Android studio and trying to take it for a test run. When I try to run my app I get the following error message

我刚刚完成安装Android工作室并尝试将其用于测试运行。当我尝试运行我的应用程序时,我收到以下错误消息

emulator: ERROR: This AVD's configuration is missing a kernel file!!
emulator: ERROR: ANDROID_SDK_ROOT is undefined

Does anybody know how to fix this????

有谁知道如何解决这个问题????

12 个解决方案

#1


23  

It is possible that you really have no system images. Double-check that $ANDROID_HOME/system-images/android-<YOUR DESIRED API>/armeabi-v7a exists and is not empty. If they really are missing - install/reinstall with SDK manager.

您可能确实没有系统映像。仔细检查$ ANDROID_HOME / system-images / android- <您的所需api> / armeabi-v7a是否存在且不为空。如果它们真的丢失了 - 使用SDK管理器安装/重新安装。

#2


17  

Go to Tools | Android | AVD Manager

转到工具| Android | AVD经理

Click the arrow under the Actions column on far right (where error message is)

单击最右侧“操作”列下的箭头(其中显示错误消息)

Choose Edit

选择编辑

Leave the default selection (For me, MNC x86 Android M)

保留默认选择(对我来说,MNC x86 Android M)

Click Next

点击下一步

Click Finish

单击完成

It saves your AVD and error is now gone from last column. And emulator works fine now.

它保存了您的AVD,现在错误从最后一列开始。而模拟器现在工作正常。

#3


10  

I got it fixed by running "C:\Program Files\Android\android-sdk\AVD Manager.exe" and repairing my broken device.

我通过运行“C:\ Program Files \ Android \ android-sdk \ AVD Manager.exe”并修复我损坏的设备来修复它。

#4


9  

Just fixed this. Hope this helps others. (Issue as in Android studio v2) This issue is for arm emulators. In this example I am using armeabi-v7a API 16

刚修好了。希望这有助于其他人。 (Android Studio v2中的问题)此问题适用于arm模拟器。在这个例子中,我使用的是armeabi-v7a API 16

The fix is three steps:

修复是三个步骤:

Step 1: Open sdk manager and make sure that you have installed ARM EABI v7a System Image

步骤1:打开sdk管理器并确保已安装ARM EABI v7a System Image

Step 2. This is the obvious case of adding the location of sdk to system variables.

步骤2.这是将sdk的位置添加到系统变量的明显情况。

Right click on "This PC" icon on desktop, then

右键单击桌面上的“此PC”图标,然后

Properties -> Advanced system settings -> Environment Variables... Then add the path to sdk as new to system variables section using variable name ANDROID_SDK_ROOT.

属性 - >高级系统设置 - >环境变量...然后使用变量名称ANDROID_SDK_ROOT将sdk的路径添加为系统变量部分的新路径。

Step 3. Restart Android Studio for changes to register. After correcting the ANDROID_SDK_ROOT is undefined issue, the emulator still can't find the kernel files even though it can see that the sdk manager installed it to

步骤3.重新启动Android Studio以进行注册更改。在纠正ANDROID_SDK_ROOT是未定义的问题之后,模拟器仍然无法找到内核文件,即使它可以看到sdk管理器将其安装到

path-to-sdk\sdk\system-images\android-16\default\armeabi-v7a\kernel-qemu

路径到SDK \ SDK \系统图像\ Android的16 \ DEFAULT \ armeabi-V7A \内核QEMU

The reason is a mix-up between the location the sdk manager installs the kernel file to and the location the emulator is looking for it.

原因是sdk管理器安装内核文件的位置与模拟器正在寻找它的位置之间存在混淆。

If you open your config.ini (Android Studio -> AVD Mananger -> "Show On Disk") for your emulator you will see the following line:

如果您为模拟器打开config.ini(Android Studio - > AVD Mananger - >“Show On Disk”),您将看到以下行:

image.sysdir.1=add-ons\addon-google_apis-google-16\images\armeabi-v7a\

image.sysdir.1 =插件\插件-google_apis-谷歌-16 \图像\ armeabi-V7A \

(i.e \path-to-sdk\add-ons\addon-....)

(即\ path-to-sdk \ add-ons \ addon -....)

Instead of changing this value in the config.ini file I copied

而不是在我复制的config.ini文件中更改此值

path-to-sdk\sdk\system-images\android-16\default\armeabi-v7a\kernel-qemu

路径到SDK \ SDK \系统图像\ Android的16 \ DEFAULT \ armeabi-V7A \内核QEMU

(kernel file from the folder sdk manager installed)

(安装了sdk manager文件夹的内核文件)

to

\path-to-sdk\add-ons\addon-google_apis-google-16\images\armeabi-v7a\

\路径到SDK \插件\插件-google_apis-谷歌-16 \图像\ armeabi-V7A \

And that was the missing kernel file. You can run the emulator. (You will need to close the Android Studio and reopen again) Give the emulator some time as it is 10x times slower compared to x86. (Mine took about 5 minutes to start)

那是缺少的内核文件。您可以运行模拟器。 (您需要关闭Android Studio并重新打开)给模拟器一些时间,因为它比x86慢10倍。 (我花了大约5分钟开始)

#5


5  

Short answer: try to create the same image using the old school <AndroidSDK>\AVD Manager.exe.

简答:尝试使用旧学校 \ AVD Manager.exe创建相同的图像。

Working in Android Studio, running all the integrated tools, it became natural to me not to use the old managers (AVD/SDK).

在Android Studio中运行,运行所有集成工具,我很自然地不使用旧管理器(AVD / SDK)。

In my case, I had this problem when used the new (integrated) AVD Manager to create devices with old system images (API 11 and below, as I've tested).

在我的情况下,当使用新的(集成的)AVD管理器来创建具有旧系统映像的设备(API 11及以下,我已经测试过)时,我遇到了这个问题。

When I tried to use the old school AVD Manager tool (located in <AndroidSDK>\AVD Manager.exe) to create these old device images, I had success.

当我尝试使用旧的AVD Manager工具(位于 \ AVD Manager.exe)创建这些旧设备图像时,我获得了成功。

#6


3  

Hey there just ran into the same issue you did, the 3rd link down in google brought me to this bit of code that throws the error,

嘿,你遇到了同样的问题,google中的第三个链接让我看到了这个引发错误的代码,

if (kernelFile == NULL) {
        kernelFile = avdInfo_getKernelPath(avd);
        if (kernelFile == NULL) {
            derror( "This AVD's configuration is missing a kernel file!!" );
            const char* sdkRootDir = getenv("ANDROID_SDK_ROOT");
            if (sdkRootDir) {
                derror( "ANDROID_SDK_ROOT is defined (%s) but cannot find kernel file in "
                        "%s" PATH_SEP "system-images" PATH_SEP
                        " sub directories", sdkRootDir, sdkRootDir);
            } else {
                derror( "ANDROID_SDK_ROOT is undefined");
            }
            exit(2);

to which the person wrote:

该人写的:

"/* If the kernel image name ends in "-armv7", then change the cpu * type automatically. This is a poor man's approach to configuration * management, but should allow us to get past building ARMv7 * system images with dex preopt pass"

“/ *如果内核映像名称以”-armv7“结尾,则自动更改cpu *类型。这是一个穷人的配置管理方法,但是应该允许我们通过dex preopt pass过去构建ARMv7 *系统映像“

So I went back in and downloaded the x86 intel atom version for my desired API level and was able to get the emulator up without the error. Hope it helps you too.....

所以我回去并为我所需的API级别下载了x86 intel atom版本,并且能够在没有错误的情况下启动模拟器。希望它也能帮到你......

#7


2  

Normally, the error will occur due to an unsuitable AVD emulator for the type of app you are developing for. For example if you are developing an app for a wearable but you are trying to use a phone emulator to run it.

通常,由于您正在开发的应用程序类型的AVD模拟器不合适,将发生错误。例如,如果您正在为可穿戴设备开发应用程序,但您正在尝试使用手机模拟器来运行它。

#8


0  

In my case (Windows 10) the reason was that I dared to unzip the android sdk into non default folder. When I moved it to the default one c:/Users/[username]/AppData/Local/Android/Sdk and changed the paths in Android Studio and System Variables, it started to work.

在我的情况下(Windows 10),原因是我敢将android sdk解压缩到非默认文件夹中。当我将其移动到默认的c:/ Users / [username] / AppData / Local / Android / Sdk并更改Android Studio和系统变量中的路径时,它开始工作。

#9


0  

I had the same error. The solution for me was change the ANDROID_HOME path. First I took a look into tools->android->sdk manager from Android Studio. In that window, we can see the path where Android Studio looks for the SDK: image

我有同样的错误。我的解决方案是更改ANDROID_HOME路径。首先,我从Android Studio中了解了tools-> android-> sdk manager。在该窗口中,我们可以看到Android Studio查找SDK的路径:image

Then I opened a Windows CMD shell, executed:

然后我打开了一个Windows CMD shell,执行:

echo %ANDROID_HOME%

but the path was different to the one in ANDROID STUDIO CONFIGURATION of the first step.

但路径与第一步的ANDROID STUDIO CONFIGURATION中的路径不同。

The solution was to change in user environment, the ANDROID_HOME, to the one of the first step: image

解决方案是将用户环境ANDROID_HOME更改为第一步:image

I finally closed the cmd shell, and opened another cmd shell to execute:

我终于关闭了cmd shell,并打开另一个cmd shell来执行:

echo %ANDROID_HOME%

the path was updated, and I could run my emulator perfectly.

路径已更新,我可以完美地运行我的模拟器。

#10


0  

  • Open Android studio.
  • 打开Android工作室。
  • Go to setting > System Setting > Android SDK
  • 转到设置>系统设置> Android SDK
  • Get the "Android SDK Location".
  • 获取“Android SDK位置”。
  • Set the environment variable ANDROID_SDK_ROOT to this value.
  • 将环境变量ANDROID_SDK_ROOT设置为此值。

It worked for me and I'm on Windows 10 and Android studio 2.3.3

它适用于我,我在Windows 10和Android studio 2.3.3上

#11


0  

  1. Go to "Edit the System Environment variables".
  2. 转到“编辑系统环境变量”。
  3. Click on New Button and enter "ANDROID_SDK_ROOT" in variable name and enter android sdk full path in variable value. Click on ok and close.
  4. 单击New Button并在变量名中输入“ANDROID_SDK_ROOT”并在变量值中输入android sdk完整路径。单击确定并关闭。
  5. Refresh AVD.
  6. 刷新AVD。
  7. This will resolve error.
  8. 这将解决错误。

#12


-1  

A common approach to follow to solve this problem.

解决此问题的常用方法。

1.CHECK your SDK manager by running from your android studio and stand alons sdk folder by executing ./android.sh helps you to find broken packages

1.通过执行./android.sh帮助您查找损坏的软件包,从您的Android工作室运行并查看您的SDK管理器并查看sdk文件夹。

  1. Try installing System emulator images with google API support than the Intel one. Just like , i solved my problem by running into another system image.

    尝试使用谷歌API支持安装系统模拟器图像,而不是英特尔。就像,我通过运行到另一个系统映像解决了我的问题。

  2. Experment on KVM based Virtulaization suggested by Google for Linux

    基于KVM的Virtulaization的实验,由Google for Linux提出

#1


23  

It is possible that you really have no system images. Double-check that $ANDROID_HOME/system-images/android-<YOUR DESIRED API>/armeabi-v7a exists and is not empty. If they really are missing - install/reinstall with SDK manager.

您可能确实没有系统映像。仔细检查$ ANDROID_HOME / system-images / android- <您的所需api> / armeabi-v7a是否存在且不为空。如果它们真的丢失了 - 使用SDK管理器安装/重新安装。

#2


17  

Go to Tools | Android | AVD Manager

转到工具| Android | AVD经理

Click the arrow under the Actions column on far right (where error message is)

单击最右侧“操作”列下的箭头(其中显示错误消息)

Choose Edit

选择编辑

Leave the default selection (For me, MNC x86 Android M)

保留默认选择(对我来说,MNC x86 Android M)

Click Next

点击下一步

Click Finish

单击完成

It saves your AVD and error is now gone from last column. And emulator works fine now.

它保存了您的AVD,现在错误从最后一列开始。而模拟器现在工作正常。

#3


10  

I got it fixed by running "C:\Program Files\Android\android-sdk\AVD Manager.exe" and repairing my broken device.

我通过运行“C:\ Program Files \ Android \ android-sdk \ AVD Manager.exe”并修复我损坏的设备来修复它。

#4


9  

Just fixed this. Hope this helps others. (Issue as in Android studio v2) This issue is for arm emulators. In this example I am using armeabi-v7a API 16

刚修好了。希望这有助于其他人。 (Android Studio v2中的问题)此问题适用于arm模拟器。在这个例子中,我使用的是armeabi-v7a API 16

The fix is three steps:

修复是三个步骤:

Step 1: Open sdk manager and make sure that you have installed ARM EABI v7a System Image

步骤1:打开sdk管理器并确保已安装ARM EABI v7a System Image

Step 2. This is the obvious case of adding the location of sdk to system variables.

步骤2.这是将sdk的位置添加到系统变量的明显情况。

Right click on "This PC" icon on desktop, then

右键单击桌面上的“此PC”图标,然后

Properties -> Advanced system settings -> Environment Variables... Then add the path to sdk as new to system variables section using variable name ANDROID_SDK_ROOT.

属性 - >高级系统设置 - >环境变量...然后使用变量名称ANDROID_SDK_ROOT将sdk的路径添加为系统变量部分的新路径。

Step 3. Restart Android Studio for changes to register. After correcting the ANDROID_SDK_ROOT is undefined issue, the emulator still can't find the kernel files even though it can see that the sdk manager installed it to

步骤3.重新启动Android Studio以进行注册更改。在纠正ANDROID_SDK_ROOT是未定义的问题之后,模拟器仍然无法找到内核文件,即使它可以看到sdk管理器将其安装到

path-to-sdk\sdk\system-images\android-16\default\armeabi-v7a\kernel-qemu

路径到SDK \ SDK \系统图像\ Android的16 \ DEFAULT \ armeabi-V7A \内核QEMU

The reason is a mix-up between the location the sdk manager installs the kernel file to and the location the emulator is looking for it.

原因是sdk管理器安装内核文件的位置与模拟器正在寻找它的位置之间存在混淆。

If you open your config.ini (Android Studio -> AVD Mananger -> "Show On Disk") for your emulator you will see the following line:

如果您为模拟器打开config.ini(Android Studio - > AVD Mananger - >“Show On Disk”),您将看到以下行:

image.sysdir.1=add-ons\addon-google_apis-google-16\images\armeabi-v7a\

image.sysdir.1 =插件\插件-google_apis-谷歌-16 \图像\ armeabi-V7A \

(i.e \path-to-sdk\add-ons\addon-....)

(即\ path-to-sdk \ add-ons \ addon -....)

Instead of changing this value in the config.ini file I copied

而不是在我复制的config.ini文件中更改此值

path-to-sdk\sdk\system-images\android-16\default\armeabi-v7a\kernel-qemu

路径到SDK \ SDK \系统图像\ Android的16 \ DEFAULT \ armeabi-V7A \内核QEMU

(kernel file from the folder sdk manager installed)

(安装了sdk manager文件夹的内核文件)

to

\path-to-sdk\add-ons\addon-google_apis-google-16\images\armeabi-v7a\

\路径到SDK \插件\插件-google_apis-谷歌-16 \图像\ armeabi-V7A \

And that was the missing kernel file. You can run the emulator. (You will need to close the Android Studio and reopen again) Give the emulator some time as it is 10x times slower compared to x86. (Mine took about 5 minutes to start)

那是缺少的内核文件。您可以运行模拟器。 (您需要关闭Android Studio并重新打开)给模拟器一些时间,因为它比x86慢10倍。 (我花了大约5分钟开始)

#5


5  

Short answer: try to create the same image using the old school <AndroidSDK>\AVD Manager.exe.

简答:尝试使用旧学校 \ AVD Manager.exe创建相同的图像。

Working in Android Studio, running all the integrated tools, it became natural to me not to use the old managers (AVD/SDK).

在Android Studio中运行,运行所有集成工具,我很自然地不使用旧管理器(AVD / SDK)。

In my case, I had this problem when used the new (integrated) AVD Manager to create devices with old system images (API 11 and below, as I've tested).

在我的情况下,当使用新的(集成的)AVD管理器来创建具有旧系统映像的设备(API 11及以下,我已经测试过)时,我遇到了这个问题。

When I tried to use the old school AVD Manager tool (located in <AndroidSDK>\AVD Manager.exe) to create these old device images, I had success.

当我尝试使用旧的AVD Manager工具(位于 \ AVD Manager.exe)创建这些旧设备图像时,我获得了成功。

#6


3  

Hey there just ran into the same issue you did, the 3rd link down in google brought me to this bit of code that throws the error,

嘿,你遇到了同样的问题,google中的第三个链接让我看到了这个引发错误的代码,

if (kernelFile == NULL) {
        kernelFile = avdInfo_getKernelPath(avd);
        if (kernelFile == NULL) {
            derror( "This AVD's configuration is missing a kernel file!!" );
            const char* sdkRootDir = getenv("ANDROID_SDK_ROOT");
            if (sdkRootDir) {
                derror( "ANDROID_SDK_ROOT is defined (%s) but cannot find kernel file in "
                        "%s" PATH_SEP "system-images" PATH_SEP
                        " sub directories", sdkRootDir, sdkRootDir);
            } else {
                derror( "ANDROID_SDK_ROOT is undefined");
            }
            exit(2);

to which the person wrote:

该人写的:

"/* If the kernel image name ends in "-armv7", then change the cpu * type automatically. This is a poor man's approach to configuration * management, but should allow us to get past building ARMv7 * system images with dex preopt pass"

“/ *如果内核映像名称以”-armv7“结尾,则自动更改cpu *类型。这是一个穷人的配置管理方法,但是应该允许我们通过dex preopt pass过去构建ARMv7 *系统映像“

So I went back in and downloaded the x86 intel atom version for my desired API level and was able to get the emulator up without the error. Hope it helps you too.....

所以我回去并为我所需的API级别下载了x86 intel atom版本,并且能够在没有错误的情况下启动模拟器。希望它也能帮到你......

#7


2  

Normally, the error will occur due to an unsuitable AVD emulator for the type of app you are developing for. For example if you are developing an app for a wearable but you are trying to use a phone emulator to run it.

通常,由于您正在开发的应用程序类型的AVD模拟器不合适,将发生错误。例如,如果您正在为可穿戴设备开发应用程序,但您正在尝试使用手机模拟器来运行它。

#8


0  

In my case (Windows 10) the reason was that I dared to unzip the android sdk into non default folder. When I moved it to the default one c:/Users/[username]/AppData/Local/Android/Sdk and changed the paths in Android Studio and System Variables, it started to work.

在我的情况下(Windows 10),原因是我敢将android sdk解压缩到非默认文件夹中。当我将其移动到默认的c:/ Users / [username] / AppData / Local / Android / Sdk并更改Android Studio和系统变量中的路径时,它开始工作。

#9


0  

I had the same error. The solution for me was change the ANDROID_HOME path. First I took a look into tools->android->sdk manager from Android Studio. In that window, we can see the path where Android Studio looks for the SDK: image

我有同样的错误。我的解决方案是更改ANDROID_HOME路径。首先,我从Android Studio中了解了tools-> android-> sdk manager。在该窗口中,我们可以看到Android Studio查找SDK的路径:image

Then I opened a Windows CMD shell, executed:

然后我打开了一个Windows CMD shell,执行:

echo %ANDROID_HOME%

but the path was different to the one in ANDROID STUDIO CONFIGURATION of the first step.

但路径与第一步的ANDROID STUDIO CONFIGURATION中的路径不同。

The solution was to change in user environment, the ANDROID_HOME, to the one of the first step: image

解决方案是将用户环境ANDROID_HOME更改为第一步:image

I finally closed the cmd shell, and opened another cmd shell to execute:

我终于关闭了cmd shell,并打开另一个cmd shell来执行:

echo %ANDROID_HOME%

the path was updated, and I could run my emulator perfectly.

路径已更新,我可以完美地运行我的模拟器。

#10


0  

  • Open Android studio.
  • 打开Android工作室。
  • Go to setting > System Setting > Android SDK
  • 转到设置>系统设置> Android SDK
  • Get the "Android SDK Location".
  • 获取“Android SDK位置”。
  • Set the environment variable ANDROID_SDK_ROOT to this value.
  • 将环境变量ANDROID_SDK_ROOT设置为此值。

It worked for me and I'm on Windows 10 and Android studio 2.3.3

它适用于我,我在Windows 10和Android studio 2.3.3上

#11


0  

  1. Go to "Edit the System Environment variables".
  2. 转到“编辑系统环境变量”。
  3. Click on New Button and enter "ANDROID_SDK_ROOT" in variable name and enter android sdk full path in variable value. Click on ok and close.
  4. 单击New Button并在变量名中输入“ANDROID_SDK_ROOT”并在变量值中输入android sdk完整路径。单击确定并关闭。
  5. Refresh AVD.
  6. 刷新AVD。
  7. This will resolve error.
  8. 这将解决错误。

#12


-1  

A common approach to follow to solve this problem.

解决此问题的常用方法。

1.CHECK your SDK manager by running from your android studio and stand alons sdk folder by executing ./android.sh helps you to find broken packages

1.通过执行./android.sh帮助您查找损坏的软件包,从您的Android工作室运行并查看您的SDK管理器并查看sdk文件夹。

  1. Try installing System emulator images with google API support than the Intel one. Just like , i solved my problem by running into another system image.

    尝试使用谷歌API支持安装系统模拟器图像,而不是英特尔。就像,我通过运行到另一个系统映像解决了我的问题。

  2. Experment on KVM based Virtulaization suggested by Google for Linux

    基于KVM的Virtulaization的实验,由Google for Linux提出