ADB
server starts on your host machine (Unix
, Windows
) and, by default, binds to port 5037
. A client (also your host machine) uses the port to send commands to a target device where the commands are executed in the system environment.
Reference:
- Android Debug Bridge on the
Android
developer site.
- ADB(Android Debug Bridge): How it works? by Tetsuyuki Kobayashi
When you run an app, its code is executed in the environment. So when you call Runtime.getRuntime().exec("adb shell command")
what you actually do is trying to start another adb
server process (on a target device now) which starts on tcp
port 5038
, since port 5037
is busy.
To sum up: you do not need to pass adb
parameter to the exec()
method, it's redundant. Instead use
Runtime.getRuntime().exec("command")
Regarding uninstalling system apps programmatically, your app must get su
first which is out of the scope of the question. Although, the following links might help you to start:
- ANDROID: How to gain root access in an Android application?
- execute shell command from android