Saturday, May 21, 2011

Test root apps on Android Emulator

The Android Emulator provide a powerful way to test Android applications. But it not allow you to test root apps because you can't get root privileges via su on the Emulator, although it's possible via adb shell.
So if you want to test root apps you have to get a rooted emulator. It's mean a su binary and optionally the superuser app which allow you to manage root apps.

Here is the list of commands you have to run while the emulator is running : 

 adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock03 /system  
 adb push su /system/xbin/su  
 adb shell chmod 06755 /system  
 adb shell chmod 06755 /system/xbin/su   

It assumes that the su binary is located in the working directory. You can find su and superuser here :
You need to run these commands each time you launch the emulator. You can write a script that launch the emulator and root it.
To install superuser persistently :
 adb install superuser.apk 

[Update April 2012] : This tip doesn't work anymore, see comments for more information


  1. Hi there..! It's all fine. That commands shows no error. But, when i tried to install shootme apk(which needs root access) has installed successfully,But it is not running in my emulator and it show that Need root access to run this application. How can i determine that my emulator is rooted..?

    1. Hi,
      What you have done should work. But I test it today and it doesn't work anymore.
      The only diference between my today's test and when I used this tip in May 2011 is the sdk version (which is different from the Android version). Back in May 2011 I guess I used the sdk r9 or r10 (my current version is r18).
      For the record, with which version of the SDK do you try and what is the AVD Android version ? For me it's sdk r18 and AVD 2.1 and 2.3.3.

      If you have the time you can test this :
      1) Download a previous sdk version (ideally r9 or r10)
      2) Download the package for Android 2.1 or 2.2.
      3) Create a new AVD 2.1 or 2.2
      4) Run the newly created AVD
      5) Perform the described steps
      6) Install your APK and test it

      Ping me if you have more informations on this issue.

    2. This works for me:
      - sdk rev 18
      - avd target: Android 2.3.3 (API level 10)


    3. adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock03 /system
      adb push su /system/xbin/su
      adb shell chmod 06755 /system
      adb shell chmod 06755 /system/xbin/su

      where should i check these commands.when i tried it in cmd,command doesn't finish executed.

  2. I have been intelligent for hours and I haven't gone through such awesome stuff.