[Java for Android App Development] Androguide.fr:
Hi guys, I made a little screen-cast of the routine used to root an android emulator.

Here's the video version, but I wrote the text version under it too.

[YOUTUBE]hx399KPutUY[/YOUTUBE]

Prerequisities​

su binary : http://d-h.st/qZ2

busybox binary : http://d-h.st/IIv

Superuser apk : http://d-h.st/Et5

(These instructions are assuming you're on ubuntu or an other debian-based linux distro, but it should be pretty easy to adapt to batch if you're on windows.)

Instructions​

1) First, create a new AVD in Eclipse or in terminal

Here's the manpage for the emulator :

Android Emulator usage: emulator [options] [-qemu args]
options:
-sysdir <dir> search for system disk images in <dir>
-system <file> read initial system image from <file>
-datadir <dir> write user data into <dir>
-kernel <file> use specific emulated kernel
-ramdisk <file> ramdisk image (default <system>/ramdisk.img
-image <file> obsolete, use -system <file> instead
-initdata <file> same as '-init-data <file>'
-data <file> data image (default <datadir>/userdata-qemu.img
-partition-size <size> system/data partition size in MBs
-cache <file> cache partition image (default is temporary file)
-cache-size <size> cache partition size in MBs
-no-cache disable the cache partition
-nocache same as -no-cache
-sdcard <file> SD card image (default <system>/sdcard.img
-snapstorage <file> file that contains all state snapshots (default <datadir>/snapshots.img)
-no-snapstorage do not mount a snapshot storage file (this disables all snapshot functionality)
-snapshot <name> name of snapshot within storage file for auto-start and auto-save (default 'default-boot')
-no-snapshot perform a full boot and do not do not auto-save, but qemu vmload and vmsave operate on snapstorage
-no-snapshot-save do not auto-save to snapshot on exit: abandon changed state
-no-snapshot-load do not auto-start from snapshot: perform a full boot
-snapshot-list show a list of available snapshots
-no-snapshot-update-time do not do try to correct snapshot time on restore
-wipe-data reset the user data image (copy it from initdata)
-avd <name> use a specific android virtual device
-skindir <dir> search skins in <dir> (default <system>/skins)
-skin <name> select a given skin
-no-skin don't use any emulator skin
-noskin same as -no-skin
-dynamic-skin dynamically construct a skin of given size, requires -skin WxH option
-memory <size> physical RAM size in MBs
-netspeed <speed> maximum network download/upload speeds
-netdelay <delay> network latency emulation
-netfast disable network shaping
-trace <name> enable code profiling (F9 to start)
-show-kernel display kernel messages
-shell enable root shell on current terminal
-no-jni disable JNI checks in the Dalvik runtime
-nojni same as -no-jni
-logcat <tags> enable logcat output with given tags
-no-audio disable audio support
-noaudio same as -no-audio
-audio <backend> use specific audio backend
-raw-keys disable Unicode keyboard reverse-mapping
-radio <device> redirect radio modem interface to character device
-port <port> TCP port that will be used for the console
-ports <consoleport>,<adbport> TCP ports used for the console and adb bridge
-onion <image> use overlay PNG image over screen
-onion-alpha <%age> specify onion-skin translucency
-onion-rotation 0|1|2|3 specify onion-skin rotation
-scale <scale> scale emulator window
-dpi-device <dpi> specify device's resolution in dpi (default 165)
-http-proxy <proxy> make TCP connections through a HTTP/HTTPS proxy
-timezone <timezone> use this timezone instead of the host's default
-dns-server <servers> use this DNS server(s) in the emulated system
-cpu-delay <cpudelay> throttle CPU emulation
-no-boot-anim disable animation for faster boot
-no-window disable graphical window display
-version display emulator version number
-report-console <socket> report console port to remote socket
-gps <device> redirect NMEA GPS to character device
-keyset <name> specify keyset file name
-shell-serial <device> specific character device for root shell
-tcpdump <file> capture network packets to file
-bootchart <timeout> enable bootcharting
-charmap <file> use specific key character map
-prop <name>=<value> set system property on boot
-shared-net-id <number> join the shared network, using IP address 10.1.2.<number>
-nand-limits <nlimits> enforce NAND/Flash read/write thresholds
-memcheck <flags> enable memory access checking
-gpu <mode> set hardware OpenGLES emulation mode
-camera-back <mode> set emulation mode for a camera facing back
-camera-front <mode> set emulation mode for a camera facing front
-webcam-list lists web cameras available for emulation
-screen <mode> set emulated screen mode
-force-32bit always use 32-bit emulator

-qemu args... pass arguments to qemu
-qemu -h display qemu help

-verbose same as '-debug-init'
-debug <tags> enable/disable debug messages
-debug-<tag> enable specific debug messages
-debug-no-<tag> disable specific debug messages

-help print this help
-help-<option> print option-specific help

-help-disk-images about disk images
-help-keys supported key bindings
-help-debug-tags debug tags for -debug <tags>
-help-char-devices character <device> specification
-help-environment environment variables
-help-keyset-file key bindings configuration file
-help-virtual-device virtual device management
-help-sdk-images about disk images when using the SDK
-help-build-images about disk images when building Android
-help-all prints all help content

2) Then, open a terminal (ctrl+alt+T) and type the following command in order to start you freshly created emulator with a bigger /system partition so we can push the su & busybox binaries :

emulator -avd yourNewAvdName -partition-size 256 -no-snapshot-load

Wait for the emulator to boot.

3) Now, cd to the directory where you put the binaries and the apk you downloaded in the prerequisities, and issue the following comands in your terminal :

adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock0 /system
adb push su /system/xbin/su
adb push busybox /system/xbin/busybox
adb install Superuser.apk
adb shell
chmod 06755 /system/xbin/su
chmod 06755 /system/xbin/busybox

4) Enjoy your Rooted emulator ;)

However, you might need to go through these steps every time you start this emulator, to avoid this hassle, here's a script containing those commands : rootavd.sh

Simply put it where you put the binaries, cd to this location and enter the following command to execute it :

bash rootavd.sh