Automatic android emulator rooting

  • Posted on: 29 April 2014
  • By: siteadm

I wrote two scripts to automate launching and rooting android emulator. If you are developing an android application which uses root access, this scripts will be really useful.

Linux ver:

#!/bin/bash
#file:rooter.sh

echo $1
if (( $# == 1 ))
then
	printf "\nRunning Emulator...\n"
	emulator -avd $1 &

	printf "\n\e[1;31mPlease wait...\e[0m\n"
	printf "\e[1;31mPress any key when emulator loaded successfully...\e[0m\n"
	read -p ""

	printf "\nMaking initial connection to emulator...\n"
	adb disconnect > /dev/null
	adb connect localhost > /dev/null
	adb disconnect > /dev/null
	adb disconnect > /dev/null
	adb connect localhost
	adb disconnect
	adb connect
fi

echo "Remounting system partition to enable write access..."
adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock03 /system > /dev/null

printf "\nUploading SU binary...\n"
adb push su /system/xbin/su > /dev/null
adb shell chmod 06755 /system > /dev/null
adb shell chmod 06755 /system/xbin/su > /dev/null

printf "\nUploading Superuser android app...\n"
adb install Superuser.apk > /dev/null

printf "\nUploading Root Checker Pro...\n"
adb install chk.apk > /dev/null

printf "\nSuccessfully Rooted!\n\n"

Usage: If you don't pass any argument, it will try to root and upload required files to already running instance (you need to have one emulator running).
Alternatively, you can pass AVD name as parameter. It will launch the given AVD and root it. Example

./rooter.sh android22 

Windows ver:

IF NOT "%1"=="" (
emulator -avd %1
echo "Running Emulator...\n"
echo "Please wait...\n"
echo "Press any key when emulator loaded successfully..."
pause
adb disconnect
adb connect
adb disconnect
adb connect
)

echo "\nMaking initial connection to emulator...\n"
adb disconnect
adb connect

echo "\nRemounting...\n"
adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock03 /system

echo "\nUploading SU binary...\n"
adb push su /system/xbin/su
adb shell chmod 06755 /system
adb shell chmod 06755 /system/xbin/su

echo "\nUploading Superuser android app...\n"
adb install superuser.apk

echo "\nUploading Root Checker Pro...\n"
adb install chk.apk

echo "\nSuccessfully Rooted!\n\n"

For required files:

download Superuser and su-bin files.

You can download root checker from:

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.