14

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.

user
  • 5,370
  • 8
  • 47
  • 75
wootank
  • 477
  • 1
  • 5
  • 18
  • 1
    I don't think this is on-topic here, try on http://android.stackexchange.com/ – Gavriel Jan 29 '16 at 02:11
  • Oh ok sorry, thanks will do! – wootank Jan 29 '16 at 02:18
  • @Gavriel, questions about rooting physical devices do belong to `AE`. Anything about Android emulator (a development tool) goes here. The question is moot though. The emulators are rooted by default. – Alex P. Feb 04 '16 at 03:51
  • Possible duplicate of [How to get root access on Android emulator?](http://stackoverflow.com/questions/5095234/how-to-get-root-access-on-android-emulator) – Laurel May 06 '16 at 02:32
  • 1
    The `adb root` command gets root access to a connected emulator. Is that what you're seeking? Also see https://stackoverflow.com/q/43923996/1682419 – Jerry101 Aug 14 '17 at 06:35

2 Answers2

9

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
user1845593
  • 1,736
  • 3
  • 20
  • 37
-9

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.

Sanf0rd
  • 3,644
  • 2
  • 20
  • 29
  • 9
    While it simplifies things a bit, it requires an active connection and account with their service. As well as more system overhead by needing vbox. It also is not rooted in the sense that applications that require root get that access as one would expect from a "rooted" phone. Also file system commands as su in shell don't seem to have any different result from the OP's mentions trying to chmod and such. – Speedz Aug 29 '16 at 14:02