emulator: ERROR:This AVD's configuration is missing a kernel file!&HAX is not installed on this mach

来源:互联网 发布:淘宝开发,用的什么软件 编辑:程序博客网 时间:2024/05/17 03:26

启动模拟器需要两个步骤:

1.创建AVD(Android Virtual Device)

2.启动emulator

一般使用Eclipse开发时,开启一个模拟器就是这么一个过程,其实命令行模式下也是这样。刚开始不知道如何命令行启动模拟器的时候就输入了一个emulator,报错了,出现如下提示:

[html] view plaincopy

  1. emulator: ERROR: You did not provide the name of an Android Virtual Device  
  2. with the '-avd <name>' option. Read -help-avd for more information.  
  3.    
  4. If you *really* want to *NOT* run an AVD, consider using '-data <file>'  
  5. to specify a data partition image file (I hope you know what you're doing).  

1.创建AVD

根据提示信息说明,需要先有一个AVD,即一个android的虚拟设备,在命令行输入android create avd当然前提是在linux中配置好了环境变量,否则会出现找不到命令的错误提示的。如果环境变量配置正确会出现了错误提示信息:

[html] view plaincopy

  1. Error: The parameters --name, --target must be defined for action 'create avd'  
  2.   
  3. Usage:  
  4.   android [global options] create avd [action options]  
  5.   
  6. Global options:  
  7.   -s --silent   Silent mode: only errors are printed out.  
  8.   -h --help     Help on a specific command.  
  9.   -v --verbose  Verbose mode: errors, warnings and informational messages are printed.  
  10.   
  11. Action "create avd":  
  12.   Creates a new Android Virtual Device.  
  13. Options:  
  14.   -c --sdcard   Path to a shared SD card image, or size of a new sdcard for the new AVD  
  15.   -s --skin     Skin for the new AVD  
  16.   -a --snapshot Place a snapshots file in the AVD, to enable persistence.  
  17.   -n --name     Name of the new AVD [required]  
  18.   -p --path     Directory where the new AVD will be created  
  19.   -t --target   Target ID of the new AVD [required]  
  20.   -f --force    Forces creation (overwrites an existing AVD)  

根据上述所提到的参数,并通过查资料得到了-t --target参数如何获得。在命令行下输入android list target,显示如下:

[html] view plaincopy

  1. android list target  
  2.   
  3. Available Android targets:  
  4. id: 1 or "android-8"  
  5.      Name: Android 2.2  
  6.      Type: Platform  
  7.      API level: 8  
  8.      Revision: 2  
  9.      Skins: WQVGA432, WQVGA400, HVGA, WVGA854, QVGA, WVGA800 (default)  

其中的id:这一行就是我们需要的target的参数

如果启动的模拟器还需要sdcard的话,还需要首先创建一个sdcard的镜像

[html] view plaincopy

  1. mksdcard -l sdcard 512M ~/xx/sdcard.img  

这样就很容易写出创建AVD的命令了

[html] view plaincopy

  1. android create avd -c ~/xxx/sdcard.img -n emulator2011 -p ~/test/ -t 1 -f  

2.启动模拟器

首先通过android list avd 查看建好的虚拟设备

[html] view plaincopy

  1. Available Android Virtual Devices:  
  2.     Name: android.2.2  
  3.     Path: /home/XXX/.android/avd/android.2.2.avd  
  4.   Target: Android 2.2 (API level 8)  
  5.     Skin: HVGA  
  6. ---------  
  7.     Name: emulator2011  
  8.     Path: /home/XXX/test  
  9.   Target: Android 2.2 (API level 8)  
  10.     Skin: WVGA800  
  11.   Sdcard: /home/XXX/sdcard.img  

然后通过命令

[html] view plaincopy

  1. emulator @emulator 2011  

就启动了第二个类型的模拟器。

其实用命令行启动模拟器和eclipse里启动是相同的。上面两个步骤就是对应eclipse中创建avd和启动模拟器的过程,使用eclipse创建avd,它会在家目录下建立.android的隐藏文件夹,将avd的信息全都放到这里面。

android create avd -c ~/Desktop/android/sdcard.img -n emulator2015 -p ~/Desktop/android/test/ -t 4 -f

emulator @emulator2015

emulator: ERROR: x86 emulation currently requires hardware acceleration!

Please ensure Intel HAXM is properly installed and usable.

CPU acceleration status: HAX is not installed on this machine (/dev/HAX is missing).

  •  前提: CPU 支持 VT (Virtualization Technology), 而且仅限于 Intel CPU

  • 首先要打开SDK Manager 下载intel haxm,下载位置:

  android-sdk\extras\intel\Hardware_Accelerated_Execution_Manager\IntelHaxm.exe

  • 下载完毕后运行IntelHaxm.exe安装,完毕后命令行执行 sc query intelhaxm ,如果 STATE RUNNING 表示安装成功。

  • 打开 SDK Manager  下载 intel x86镜像

  • 创建AVD,CPU选择 intel atom x86

出现emulator: ERROR:This AVD's configuration is missing a kernel file!!的原因是在你的sdk下缺少相应的kernel-qemu文件。     可按如下步骤查找原因:执行android list avd ,查看你创建的AVD其中ABI:后面的关键字记住,然后进入你的SDK中..\..\sdk\system-images\android-17,我创建的AVD是API level 17,所以查看的文件是android-17,看这个文件夹中是否有X86的文件我之前就是因为缺少X86的文件,所以一直报错。      解决方法:进入Android SDK Manager,查看相应AVD的Packages缺少X86文件夹就下载Intel x86 Atom System Image缺少armeabi-v7a文件夹就下载ARM EABI v7a System Image下载完成就OK 了!       然后再使用命令emulator @(avd名字) - verbose查看其中有一行显示如下,报错就是因为它找不到x86下面的kernel-qemu文件!!!
0 0