如何编译android x86模拟器

发布网友 发布时间:2022-04-22 22:28

我来回答

2个回答

热心网友 时间:2023-10-05 23:25

首先你需要设置一下emulator工具的目录之类的
要在.bashrc中新增环境变量,如下
ANDROID_PRODUCT_OUT=~/android/out/target/proct/generic
ANDROID_PRODUCT_OUT_bin=~/android/out/host/linux-x86/bin
这里是设置你的输出文件的位置和bin工具目录
然后在命令行输入:
export path=${path}:${ANDROID_PRODUCT_OUT_bin}:${ANDROID_PRODUCT_OUT};
上面是导入了相关的配置,然后使之生效。
source ~/.bashrc
接着切换到输出的system文件夹
cd ~/android/out/target/proct/generic
然后来创建模拟器
emulator -system system.img -data userdata.img -ramdisk ramdisk.img
如果你运气够好的话,也许现在已经在运行了,不过我运气明显不够好。
提示一:
emulator: ERROR: You did not specify a virtual device name, and the system
directory could not be found.
If you are an Android sdk user, please use ‘@<name>’ or ‘-avd <name>’
to start a given virtual device (see -help-avd for details).
Otherwise, follow the instructions in -help-disk-images to start the emulator

既然人家提示了,那就按照步骤走吧,输入命令:
emulator -help-avd
接着提示如下:
use ‘-avd <name>’ to start the emulator program with a given Android
Virtual Device (a.k.a. AVD), where <name> must correspond to the name
of one of the existing AVDs available on your host machine.
See -help-virtual-device to learn how to create/list/manage AVDs.
As a special convenience, using ‘@<name>’ is equivalent to using
‘-avd <name>’.
跟着提示继续走,输入命令:
emulator -help-virtual-device
又是提示了:
An Android Virtual Device (AVD) models a single virtual
device running the Android platform that has, at least, its own
kernel, system image and data partition.
Only one emulator process can run a given AVD at a time, but
you can create several AVDs and run them concurrently.
You can invoke a given AVD at startup using either ‘-avd <name>’
or ‘@<name>’, both forms being equivalent. For example, to launch
the AVD named ‘foo’, type:
emulator @foo
The ‘android’ helper tool can be used to manage virtual devices.
For example:
android create avd -n <name> -t 1 # creates a new virtual device.
android list avd # list all virtual devices available.
Try ‘android –help’ for more commands.
Each AVD really corresponds to a content directory which stores
persistent and writable disk images as well as configuration files.
Each AVD must be created against an existing sdk platform or add-on.
For more information on this topic, see -help-sdk-images.

延伸1):
Android x86模拟器Intel Atom x86 System Image配置与使用方法

大家现在开发使用的Android 模拟器模拟的是 arm 的体系结构(arm-eabi),因此模拟器并不是运行在x86上而是模拟的arm,所以我们调试程序的时候经常感觉到非常慢,大部分开发者应该都深有体会。
针对这种情况,前段时间intel推出了支持x86的Android模拟器,这将大大提高启动速度和程序的运行速度,这将允许Android模拟器能够以原始速度(真机运行速度)运行在使用intel x86处理器的电脑中,各位开发者有福了,下面将为大家展示使用方法。

一、首先下载intel提供的 intel® Hardware Accelerated Execution Manager 1.0.1(R2)

requirement:
1. requires the Android* SDK to be installed (version 17 or higher). SDK17或者以上
2.intel® processor with support for VT-x, EMT, and Execute Disable (XD) bit functionality intel的cpu:并支持VT-X(虚拟化技术)、可扩展位、Execute Disable bit。(均需要保证在bios中开启Enable)
3. At least 1 gb of available ram 1G以上内存,否则安装不了

满足硬件和软件要求之后,就可以开始安装了,一直下一步至安装成功。途中有个地方选择分配给HAXM内存大小,一般默认就好,分太多会拖慢整机速度。

安装成功后命令行输入sc query intelhaxm,查看运行状态: state is: “4 RUNNING” ,即代表安装成功。需要更改分配内存,重新运行一下安装程序选择change即可修改。
还可以使用以下指令手动开启和关闭:
Stop: sc stop intelhaxm

Start:
sc start intelhaxm

满足软硬件条件,若提示如下Error:but intel Execute Disable bit (XD) is not turned on......
(需要开启系统数据执行保护功能dep,下午纠结了好久才查到。官网原文:Windows* hosts may need to enable dep (Data Execution Prevention) in addition to intel XD)
命令行使用指令:bcdedit.exe /set nx optin 打开即可,需要重启电脑

二、下载Intel Atom x86 System Image
1. 从SDK Manager下载:打开SDK Manager,展开至Android2.3.3(API10)(注意:目前只有2.3.3和4.0.3(Ice Cream Sandwich)有x86的Image),需要和2.3.3的SDK Platform配合使用。

2.使用avd Manager创建一个新的avd: Hardware Property里面选择gpu emulation yes 还有 Keyboard support yes

3.开始使用飞速的模拟器吧,各种爽歪歪
好的工具可以更有效率的开发APP,让我们从此告别那龟速的模拟器吧

热心网友 时间:2023-10-05 23:25

首先你需要设置一下emulator工具的目录之类的,这个不细说了,
要在.bashrc中新增环境变量,如下
ANDROID_PRODUCT_OUT=~/android/out/target/proct/generic
ANDROID_PRODUCT_OUT_BIN=~/android/out/host/linux-x86/bin
这里是设置你的输出文件的位置和bin工具目录,不用多解释吧?
然后在命令行输入:
export PATH=${PATH}:${ANDROID_PRODUCT_OUT_BIN}:${ANDROID_PRODUCT_OUT};
上面是导入了相关的配置,然后使之生效。
source ~/.bashrc
接着切换到输出的system文件夹
cd ~/android/out/target/proct/generic
然后来创建模拟器
emulator -system system.img -data userdata.img -ramdisk ramdisk.img
如果你运气够好的话,也许现在已经在运行了,不过我运气明显不够好。
提示一:
emulator: ERROR: You did not specify a virtual device name, and the system
directory could not be found.
If you are an Android SDK user, please use ‘@<name>’ or ‘-avd <name>’
to start a given virtual device (see -help-avd for details).
Otherwise, follow the instructions in -help-disk-images to start the emulator

既然人家提示了,那就按照步骤走吧,输入命令:
emulator -help-avd
接着提示如下:
use ‘-avd <name>’ to start the emulator program with a given Android
Virtual Device (a.k.a. AVD), where <name> must correspond to the name
of one of the existing AVDs available on your host machine.
See -help-virtual-device to learn how to create/list/manage AVDs.
As a special convenience, using ‘@<name>’ is equivalent to using
‘-avd <name>’.
跟着提示继续走,输入命令:
emulator -help-virtual-device
又是提示了:
An Android Virtual Device (AVD) models a single virtual
device running the Android platform that has, at least, its own
kernel, system image and data partition.
Only one emulator process can run a given AVD at a time, but
you can create several AVDs and run them concurrently.
You can invoke a given AVD at startup using either ‘-avd <name>’
or ‘@<name>’, both forms being equivalent. For example, to launch
the AVD named ‘foo’, type:
emulator @foo
The ‘android’ helper tool can be used to manage virtual devices.
For example:
android create avd -n <name> -t 1 # creates a new virtual device.
android list avd # list all virtual devices available.
Try ‘android –help’ for more commands.
Each AVD really corresponds to a content directory which stores
persistent and writable disk images as well as configuration files.
Each AVD must be created against an existing SDK platform or add-on.
For more information on this topic, see -help-sdk-images.

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com