root Android emulator

一个的简单的脚本就可以实现自动化root,以下代码在 Android 4.4.2 的 emulator上实验成功。

1
2
3
4
5
6
sudo ./adb start-server
./adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock0 /system
./adb push su /system/xbin/su
./adb install Superuser.apk
./adb shell chmod 06755 /system/xbin/su
./adb shell /system/xbin/su -d

其中涉及的二进制文件都可以从 [2] 下载,最关键的步骤是执行su -d,不执行的话SuperSu会报找不到su的二进制文件。

关于android 的emulator有个特性,/system 下的所有更改在下次重启时会丢失。解决这个问题的方法有很多种,最简单的方法是从tmp目录下拷贝emulator-xxx 文件到avd目录。avd目录默认在 ~/.android/avd

/tmp/android-user/emulator-xxxx, 将这个文件重命名为system.img,这样重启后,/system下的修改不会丢失。

[1] http://www.claudxiao.net/2013/10/persistent-change-emulator-system-partition/
[2] http://download.chainfire.eu/589/SuperSU/UPDATE-SuperSU-v2.16.zip
[3] http://stackoverflow.com/questions/15417105/forcing-the-android-emulator-to-store-changes-to-system


root Android emulator
http://usmacd.com/cn/root_android_emulator/
Author
henices
Posted on
March 10, 2015
Licensed under