2

I want to get a root shell since my adbd crashes. But the -shell option does not work. Meanwhile, I found out, that you can get a shell by using -show-kernel. But I would like to communicate with the root shell by TCP. There's also an open issue at google: https://code.google.com/p/android/issues/detail?id=202760

When starting an Android emulator (SDK 24.4.1) on Linux by command line, you should be able to get a root shell by using the -shell command-line option. At least that's what the manual says

Create a root shell console on the current terminal. You can use this command even if the adb daemon in the emulated system is broken. Pressing Ctrl-C from the shell stops the emulator, instead of the shell

But when starting the emulator like

emulator -netdelay none -netspeed full -avd nougat-x86_64 -gpu off -no-window -shell

I do see the shell output of the Android emulator booting, but I cannot send any commands to it, i.e. ls.

Also, opening a TCP port for the shell and communicating via telnet shows the same behavior.

emulator -netdelay none -netspeed full -avd nougat-x86_64 -gpu off -no-window -shell-serial tcp::4444,server,nowait
telnet localhost 4444

There's not much information about this topic on the internet, but perhaps someone already dealt with this topic.

2
  • This seems to have also been the topic at stackoverflow.com/questions/39374975/…
    – D. Joe
    Nov 4, 2016 at 16:16
  • Use adb shell of course. If I recall an emulator would typically give you that shell as root by default. If not, for a configuration which supports offering a root shell, do adb root first (rather obviously, that is not something that works on a consumer device configured in the way that Android was designed for consumer devices to be configured) Mar 18, 2019 at 16:26

1 Answer 1

0

From Android source line 698, seems the -shell option is as same as -logcat option, thus I think the documentation is not described well and of course the -shell option won't bring you an interactive root shell from the virtual serial. Maybe I'm wrong, I only tested this on macOS.

With a further test, as same as this guy's post, the -show-kernel will actually get you the kernel log and an interactive rootable console.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .