Patching a file into system.img for use with android emulator
I need to patch a file into the system.img file used by the Android emulator, specifically I want to add an ARM binary to the /system/bin directory.
I have this binary pre-compiled and it works in my emulator perfectly, but I can't simply remount system.img as rw and adb push it because the change is non-persistent across reboots. I tried this on a copy of system.img and passing it to the emulator with -system but that was non-persistent to sadly.
In the ideal world I want to modify the "make sdk" process so that the sdk build process automatically includes my binary when it produces 开发者_运维问答system.img. Can this be done?
If this isn't possible, is there anyway of patching it into the image manually?
Thanks a lot.
I was interested in permanently modifying the /system folder and tried unpacking the system.img file which went ok, but I failed to create a new img that the emulator was happy with (using the mkyaffs2 and unyaffs2 tools to extract and create a new system.img).
Instead I found a much easier solution:
- Remove everything from the /data/ directory (except lost+found)
- Copy the contents of /system into your /data folder
- Make your desired changes to /data/
- Kill the emulator
You now move your ~/.android/avd/MYANDROID.avd/userdata-qemu.img to ~/system.img (or wherever) and startup your emulator with your new system image:
emulator -debug all -show-kernel -verbose -avd MYANDROID -no-boot-anim \
-gpu on -partition-size 800 -system [path to your new system.img]
The /data folder is where the userdata-qemu.img file gets mounted. It gets created the first time the emulator is run and will get recreated if you delete it. (though your installed apps will disappear). BY populating it with the contents of the /system folder and then making your desired modifications you have created a replacement for the system.img file.
system.img
replace with original one so you need give patches whenever your emulator boots check logcat & then using ADB push you manually push the patches.
精彩评论