How to Root an Android Emulator?

无人久伴 提交于 2019-12-08 15:29:05

问题


I know there are quite a few question like this around but none of them really seems to work for me.

I am writing a program that automatically updates and installs itself, however to install the update it requires user confirmation but I do not want this as the device I will deploy on will never be physically used by anyone. So to try work around this I want to root the device and use a runtime command in the code to get it to just install.

To test this out I want to try it on the (AVD) emulator first however it (obviously) needs to be rooted. So how would i go about this?

I have tried commands in the adb shell (and out of it with the adb shell) like:

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

and a few others I can't find again at this moment but they will always give me errors such as cannot stat 'su' and stuff like that (will edit if i can find the commands and recreate again) or they just don't say anything and it doesn't appear to work.

If it helps i'm using xamarin in visual studio.


回答1:


You can use https://www.genymotion.com/. All devices created are rooted by default. For example start a device then type adb shell command. It will open a rooted shell.




回答2:


When working with android emulators, just do:

  • adb.exe root - restart adbd with root permissions
  • adb.exe unroot - restart adbd without root permissions

You can find adb.exe at: android_sdk\platform-tools\

You can confirm if the device is rooted by doing:

adb.exe shell

Inside the shell type: whoami. Then type exit to exit the shell

Example

P:\Android\sdk\platform-tools>adb.exe shell
generic_x86:/ $ whoami
shell
generic_x86:/ $ exit

P:\Android\sdk\platform-tools>adb.exe root

P:\Android\sdk\platform-tools>adb.exe shell
generic_x86:/ # whoami
root
generic_x86:/ # exit

P:\Android\sdk\platform-tools>adb.exe unroot

P:\Android\sdk\platform-tools>adb.exe shell
generic_x86:/ $ whoami
shell
generic_x86:/ $ exit


来源:https://stackoverflow.com/questions/35075702/how-to-root-an-android-emulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!