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
https://developer.android.com/studio/run/emulator-commandline.html (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 can not 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. Thanks in advance!
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, doadb 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) – Chris Stratton Mar 18 '19 at 16:26