14

Yesterday when removing bloatware from my phone, I accidentally uninstalled an 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 me 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.

Your help would be really appreciated to get my camera back.

My phone is an unrooted Samsung s7 Edge running Oreo 8.0.

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

6 Answers 6

21

Technically the command adb shell pm unistall -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.

1
2

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 give 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

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/app-priv 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.

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.

0

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

You must log in to answer this question.

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