android - 从源代码构建 Android 后运行模拟器

标签 android android-emulator linux-kernel

我能够将最新的 android 源代码下载到 Ubuntu 32 位虚拟机(主机:Windows 7 64 位)。构建完成,没有任何错误。

然后我尝试关注 these instructions ,其中提到我应该在源代码的根目录上运行模拟器。但是,当我尝试这样做时,我收到一条错误消息,指出找不到此命令。

所以我去了 out/host/linux-x86/bin 文件夹,我发现 emulator* 有几个文件:

  • 模拟器
  • 模拟器臂
  • emulator_renderer
  • 模拟器-ui
  • emulator-x86

当我在这里键入 emulatoremulator-x86 时,它也不起作用。这是我得到的错误:

xxxx/out/host/linux-x86/bin$ ./emulator-x86
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-x86 -help-disk-images 时,我看到以下内容:

If you are building from the Android build system, you should
have ANDROID_PRODUCT_OUT defined in your environment, and the
emulator shall be able to pick-up the right image files automatically.
See -help-build-images for more details.

我自己构建了这个,所以我认为 ANDROID_PRODUCT_OUT 是在我的环境变量中设置的,但我没有看到它。所以我认为我应该运行一些其他的 shell 脚本来获取该设置。

我查看了 img 文件,我在 out/target/product/generic 的位置看到了几个:

  • ramdisk.img
  • system.img
  • userdata.img

任何人都可以对此有所了解并帮助我下一步应该做什么吗?我是 Android 新手,对此进行了一些研究,但找不到任何类似的问题。

最佳答案

我不知道您为哪个产品进行构建,但要运行模拟器,您可以使用以下命令:

out/host/linux-x86/bin/emulator -sysdir out/target/product/generic/ -system out/target/product/generic/system.img -ramdisk out/target/product/generic/ramdisk.img -data out/target/product/generic/userdata.img -kernel prebuilt/android-arm/kernel/kernel-qemu -sdcard sdcard.img -skindir sdk/emulator/skins -skin WVGA800 -scale 0.7 -memory 512 -partition-size 1024

只需将其复制到 Android 源文件夹根目录下的 .sh 文件中并运行此文件。或者你可以直接运行它,但你应该首先 chdir 到你的 Android 源文件夹根目录。

并且不要忘记使用命令mksdcard在根文件夹中创建一个sdcard图像。

关于android - 从源代码构建 Android 后运行模拟器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9022750/

相关文章:

Android - 更新支持库 com.android.support :cardview-v7 to version 27. 0.2 未知属性问题

android - Android 上的阿拉伯语低于 3.0

android - Intent 和编辑文本问题

c - 在 file_operations 中实现 mmap - 将页面数组映射到虚拟空间

linux - 对硬件抽象层的说明

java - 基于属性将 XML 元素反序列化为不同的类型

java - 简单的进出动画与android

Android:禁用复选框不响应点击事件

android - Flutter 无法准备运行隔离

gcc - 夹板与 gcc : are external static code analysis tools worth the effort for C codebases?