Flashing Android IMG

Recently, I made some changes to android webkit and compile android source. Then I need to flash my android Nexus S with the fresh built img.

(fastboot is a command/executable like adb)

0. unlock bootloader

note: in order for fastboot and adb commands to find devices, the right usb driver needed to be installed through Window device manager. In device manager, right click on devices (with a ‘?’ on it if driver is not installed), update driver from local file system (sdk–extras–google–driver). Sometimes, if “adb devices” cannot find devices, just try another usb port of your computer.

$ fastboot oem unlock

  1. Reboot bootloader

    $ fastboot reboot-bootloader

  2. flash android image

$ fastboot -w update image-yakju-icl53f.zip

  • note that there’re several img files in the zip file, userdata.img, system.img, boot.img, recovery.img, we can just make the compress the img files into a zip file.
  • before compiling android source for specific device, we need to get the proprietary binaries and extract them under root directory of android source. (http://source.android.com/source/building-devices.html)

But after flash the self-made android image, I find that the Google apps do not exit in this build, like Google Play. I can’t even log my Google account on for this device. So What I need to do is to install the so-called Google_apps from a zip package (downloaded from http://wiki.rootzwiki.com/Google_Apps). I put the zip file on sdcard, reboot to fastboot mode, enter recover mode (I downloaded the latest TWRP custom recovery image from http://www.cultofandroid.com/23782/rooting-the-google-nexus-4-the-right-way-how-to/), update/install from sdcard using the zip file. Then I reboot, the google play app and other Google apps exist in the system now.

But i find that i can’t log onto my google account for google play store. So i have to install apps (for experiment of my research) through “adb install xxx.apk” command. Here’s the batch file for windows (apks and adb.exe are in the same directory):

for /r . %%g in (*.apk) do 
@echo %%g
adb install %%g

several ago, i wrote one for Ubuntu:

for f in $FILES
echo “Processing $f file…”
adb install $f
echo “finished instaling $f file…”
# take action on each file. $f store current file name
# cat $f

Decompile apks (batch)

use command apktool to decompile a bunch of apks on windows: (apktool d xxx.apk)

for /r . %%g in (*.apk) do apktool d %%g 

use dex2jar to decompile a bunch of apks on windows: (d2j-dex2jar.bat xxx.apk)

for /r . %%g in (*.apk) do ..\d2j-dex2jar.bat %%g


1. http://mobilecon.info/flashing-google-nexus-factory-image.html

2. http://xzhou.wordpress.com/2010/08/02/compiling-android-for-develop-phone-on-ubuntu-and-flash-into-dream/


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s