I am building an app for some set of rooted phones I have. I was wondering if there is any way that I could uninstall a system app which comes with the phone running some code from my app.
I have tried running commands like adb shell pm clear COM.PACKAGE.NAME
from the phone itself by Runtime.getRuntime().exec()
, but the output of the command is as follows:
cannot bind 'tcp:5038
* Daemon not running. Starting it now on port 5038*
Why?
ADB
server starts on your host machine (Unix
,Windows
) and, by default, binds to port5037
. 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
developer site.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 anotheradb
server process (on a target device now) which starts ontcp
port5038
, since port5037
is busy.To sum up: you do not need to pass
adb
parameter to theexec()
method, it's redundant. Instead useRegarding 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: