0

With a PC connection and adb, I can install packages by running

adb install foobar.apk

There is also an option to downgrade a package to an earlier version and keep data (as long the app itself did not introduce any incompatibilities in the later version):

adb install -r -d foobar.apk

Is there an equivalent local command which I could run from a terminal session (or any other way to downgrade without a PC connection)?

1 Answer 1

0

The local pm command can do this. You need the following things:

  • A terminal app. (adb shell will also work, but then you might just as well use adb install).
  • A way to get root permission on the command line (usually su)
  • A copy of the APK on the device, e.g. by downloading it using a web browser.

Open the terminal app, then run:

su
pm install -r -d /sdcard/download/foobar.apk

Command line options are the same as for adb install: -r will replace existing packages, -d will downgrade if necessary.

5
  • adb shell doesn't need root access which is a big step for majority of the users. So you can't say them equivalent, but both are commandline solutions. Btw there are workarounds to run adb shell on device. Commented Oct 9, 2019 at 17:54
  • pm install is equivalent in that it installs APKs and is capable of downgrading, just like adb install. It is true, though, that pm requires root while adb install doesn’t. adb shell just gets you a command line, which is the same thing that the terminal app does; neither requires root per se. Or did you mean adb install? If you have a way to run adb install on the device itself, without requiring a PC connection, feel free to post this as an answer.
    – user149408
    Commented Oct 17, 2019 at 13:50
  • adb install executes adb shell pm install at back end, so they are essentially the same thing. Point is to connect adb server to adbd, then you may execute any command adb XYZ. See this: android.stackexchange.com/a/216474/218526 Commented Oct 18, 2019 at 0:54
  • @IrfanLatif why not make this another answer? Both pm and local adb do the trick, each coming with their own prerequisites. Which of these two is easier depends mostly on your local device configuration.
    – user149408
    Commented Oct 22, 2019 at 11:07
  • It's already answered many times in different questions. You may consider updating your answer. Commented Oct 22, 2019 at 22:18

You must log in to answer this question.

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