21

My phone is an unrooted Samsung Galaxy S7 Edge running Oreo 8.0. Yesterday when removing bloatware from my phone, I accidentally uninstalled a system app using the adb command:

pm uninstall -k --user 0 

I suspect the culprit to be com.sec.factory.camera, as since that unfortunate event, the camera app crashes every time I try to launch it.

I tried reinstalling it using either of these two commands

pm install com.sec.factory.camera
pm install --user 0 com.sec.factory.camera

but they returned a "can't open non-file" error message.

I tried as well downloading the APK on my phone and installing it from Android, but at the end of the installation process, I got a "not installed application" message.

How to reinstall an uninstalled system app through ADB?

1
  • 1
    The app must still be there somewhere inside /system, so try finding its absolute location and installing from there.
    – Firelord
    Commented Jul 31, 2019 at 12:03

7 Answers 7

29

Technically, the command adb shell pm uninstall -k --user 0 <package_name> does not uninstall an app from the device. Instead, it just removes it from a user.

There are a couple of ways to get the removed app back to the user: one way is through an ADB shell with the command:

adb shell cmd package install-existing <package_name>

Or an extreme way would be through a factory reset of the device.

2
  • 1
    I get unkown command: install-existing Commented Sep 8, 2021 at 22:33
  • Depending on the OS/terminal, the command after adb shell and cmd might need to be enclosed with quotes.
    – Andrew T.
    Commented Sep 8, 2023 at 14:14
4

For those circumstances when install-existing solution is unavailable the dandan657's method works. But I've found an easier way to look for the location of the existing APK. In ADB shell type:

pm list packages -f -u | grep <package name>

You will get the result in this format:

package:<full path to the apk>=<package name>

Example:

package:/system/app/Photos/Photos.apk=com.google.android.apps.photos

These are the useful optional parameters that pm list packages command accepts:

-f: See their associated file.
-d: Filter to only show disabled packages.
-e: Filter to only show enabled packages.
-s: Filter to only show system packages.
-3: Filter to only show third party packages.
-i: See the installer for the packages.
-u: Also include uninstalled packages.
--user <USER_ID>: The user space to query.

Tip: Using the above it might be a good idea to have variously filtered package lists saved for the future reference.

Reference: https://android-doc.github.io/tools/help/shell.html#pm

3

I uninstalled the package com.google.android.partnersetup when I was going to uninstall other app. I couldn't recover it with Bo Lawson's method. Instead, I found this way:

pm dump com.google.android.partnersetup | grep Path    

This gives us some paths. One of them is the one I'm going to use:
"codePath=/system/priv-app/GooglePartnerSetup"

Finally, I install the app which is in that direction. The app has the same name of the app folder, with ".apk" at the end:

pm install -r --user 0 /system/priv-app/GooglePartnerSetup/GooglePartnerSetup.apk

I hope this helps, but I don't know what exactly does this do.

My source: comment from Mac23.

2

My way

  1. Install Solid Explorer
  2. Open Settings
  3. Enable Root Storage
  4. Back to main
  5. Open hamburger menu
  6. Select root
  7. Go to system
  8. Go to app
  9. Search your app
  10. Install it
1

Bo Lawson's answer has worked perfectly and is the best answer for those without root access, this is what I did:

Install the app again by:

adb shell cmd package install-existing <package-name>

Then uninstall it by:

adb shell pm uninstall <package-name>

Then install the app or its update from Google Play or from your browser.

1

I had the same problem with my Android 6 phone. On Android 6, the adb shell cmd ... commands are not available.

I fixed it the following way (needs root or custom recovery with full file system access):

  1. Locate the APK file of the deleted package in the /system/priv-app folder
  2. Move the APK file to a different location (e.g. /data/app)
  3. Reboot phone
  4. Move the APK file back to its original location
  5. Reboot phone

I hope this can help others who also don't have Android 7 or newer.

0

I accidentally uninstalled the default file manager and then was unable to set shared dirs for new apps and other essential functions.

Once I found out the package name included documentsui, searching for that in App Manager (free, available on F-Droid) allowed me to just click a greyed-out listing, where it then asked me whether I wanted to reinstall it. Full functionality restored.

Hope that helps someone.

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Sep 7, 2023 at 21:05

You must log in to answer this question.

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