在 Android 模拟器上运行自定义 ROM

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25985384/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 09:53:55  来源:igfitidea点击:

Run custom ROM on Android Emulator

androidandroid-emulator

提问by Mike Phoenix

I downloaded a third-party ROM, and I want to run it on the emulator first before flash it into the phone. Here is the contents of cm-11-20140911-NIGHTLY-p3110.zip:

我下载了一个第三方ROM,我想先在模拟器上运行它,然后再将它刷入手机。以下是内容cm-11-20140911-NIGHTLY-p3110.zip

 1. boot.img
 2. file_contexts
 3. META-INF/
 4. recovery/
 5. system/

I unpacked boot.imgusing the script unpack-bootimg.pland get boot.img-kernel, and boot.img-ramdisk.cpio.gz.Then I repacked the system using the make_ext4fsand got system.img.

boot.img使用脚本解压unpack-bootimg.pl并得到boot.img-kernelboot.img-ramdisk.cpio.gz.然后我使用make_ext4fs和得到重新打包系统system.img

I created an AVD and execute:

我创建了一个 AVD 并执行:

emulator -system ~/cm11/system_new.img -ramdisk ~/cm11/boot.img-ramdisk.cpio.gz -kernel ~/cm11/boot.img-kernel -avd and442

emulator -system ~/cm11/system_new.img -ramdisk ~/cm11/boot.img-ramdisk.cpio.gz -kernel ~/cm11/boot.img-kernel -avd and442

but all I got is nothing, the emulator screen is just black. There is no log message from adb -s emulator-5554.

但我得到的只是什么,模拟器屏幕只是黑色。没有来自 的日志消息adb -s emulator-5554

Now I am confused:

现在我很困惑:

  • can the third-party ROM be tested by the emulator?
  • Am I doing the right way?
  • 第三方ROM可以用模拟器测试吗?
  • 我做对了吗?

回答by Sanket Prabhu

Yeah why not. We can flash third party ROM on android AVD.But first you must know the following things:

是啊,为什么不呢。 我们可以在 android AVD 上刷第三方 ROM。但首先你必须知道以下几点:

1. Android Emulator is itself a device like your Moto G or Xperia

1. Android Emulator 本身就是一个类似于 Moto G 或 Xperia 的设备

2. Every ROM is device specific (Support device specific Kernel)

2. 每个 ROM 都是特定于设备的(支持特定于设备的内核)

(on many sites/blogs you got info like you have to replace system.imgfile from .android\avd\avdname.avd but it is technically incorrect because you also require ramdisk.img.)

(在许多站点/博客上,您得到的信息是您必须从 .android\avd\avdname.avd替换system.img文件,但技术上不正确,因为您还需要ramdisk.img。)

To do this you need to create your own AOSP repo by downloading the particular repo and have to build your own .img files)

为此,您需要通过下载特定的存储库来创建自己的 AOSP 存储库,并且必须构建自己的 .img 文件)

  • You can do it by 2 ways :

    1. replace files system.img & ramdisk.img from location .android\avd\avdname.avd

    2. build your own AOSP. before.. make in "lunch" select target as: Emulator(like: genericX86) i.e generate all emulator specific .img files

  • 你可以通过两种方式做到这一点:

    1. 从位置 .android\avd\avdname.avd 替换文件 system.img 和 ramdisk.img

    2. 构建您自己的 AOSP。之前..在“午餐”中选择目标为:模拟器(如:genericX86)即生成所有模拟器特定的.img文件

I have tried many things. It's a bit critical but interesting. Following links may help you:

我尝试了很多东西。这有点关键但很有趣。以下链接可能对您有所帮助:

To Run your cooked Rom on Emulator(link down. try this, from archive.org).

在模拟器上运行你熟的 Rom(链接下来。试试这个,来自 archive.org)。

To Create AOSP Project

创建 AOSP 项目