Get root access via su in Android emulator

I need root access via su to dine in the TcpDump binary (I am working on a kind of android sniffer). I am using this code:

try { Process process = Runtime.getRuntime().exec("su"); DataOutputStream os = new DataOutputStream(process.getOutputStream()); os = new DataOutputStream(process.getOutputStream()); os.writeBytes("/data/local/tcpdump-arm -c 10 -s 0 -w /data/local/out.txt\n"); os.writeBytes("exit\n"); os.flush(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } 

It works fine on the root phone, but I want to achieve this in the emulator. By default, you cannot get root privileges via su on the emulator (although this is possible through the adb shell).

I found this post

But this does not work for me. I read that this advice will not work with the revised version of sdk, but it does not say what it will work with. I am trying to run Android 2.1 with sdk 10 and avd.

+5
source share
3 answers

Ok, I solve the problem myself: /

It works with sdk version 10 and in avd 2.2. The problem with the prompt I followed earlier is the recovery step. Here is the list of commands working for me (excerpt from http://forum.xda-developers.com/showthread.php?t=821742 ):

 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 adb install superuser.apk 

Here you can get the su application and the superuser application: http://forum.xda-developers.com/showthread.php?t=682828

You must do this every time you start the emulator.

+8
source

I managed to get superuser.apk to stay between reboots by removing /system/app/SdkSetup.apk

I just checked again and it was recreated, but I still have Superuser.apk between my reboots.

I would also recommend pushing the busybox binary with su.

+1
source

Note that the steps from abd also worked for the AVD emulator with OS 2.3.3 Gingerbread. I downloaded su-2.3.6.1-signed.zip from the provided link.

In addition, I created a .bat file containing the commands provided by abd for instant execution.

0
source

All Articles