Customize an Android system.img

Last Modified: Wed, 30 Nov 2011 02:08:33 +0000 ; Created: Wed, 30 Nov 2011 02:08:33 +0000

I needed to customize the system.img for a generic build (emulator) of an Android 2.3.7b1 ROM. I wanted to add Google Maps to it (as well as Market, etc) and run it in the emulator for a school project of a custom ROM.

I tried adding the necessary files to a running ROM, but the system.img file is reset each time you restart the emulator. There was a temporary copy of the modified in-memory version in my account profile temp folder, but copying it just gave an unbootable image. In the end I found doing a ROM build on my Linux machine and extracting the system.img from the build, adding the files, and repackaging worked.

You need:

  • system.img to modify (.\android-sdk-windows\platforms\android-10\images is one place to look)
  • GoogleServicesFramework.apk and whatever Google apps you want (like Vendor.apk, etc).
    • Copy from your existing phone or check out Google Apps download section for CyanogenMod
  • Linux (I used Ubuntu 11.04 64-bit)
  • unyaffs - (I used the precompiled binary without issue)
  • mkyaffs2image - (You also get it if you are building a ROM)

Steps

  1. mkdir EXTRACTED
  2. cd EXTRACTED
  3. ~/unyaffs ~/system.img
  4. Copy whatever you need into the extracted content
    • Example: cp ~/GoogleServicesFramework.apk ~/EXTRACTED/app/
  5. mkyaffs2image EXTRACTED newsystem.img