133

I have adb running and device is connected to my system in debugging mode,

I want to uninstall app using intent launch using adb shell am start <INTENT>

I don't want to uninstall using adb uninstall com.company.apppackage and I don't want to do it even by using adb shell pm uninstall com.company.apppackage

How can I send an intent with android.intent.action.DELETE action for a specific package allowing the user to see the prompt and uninstall the program?

7 Answers 7

226

Use this command in cmd:

adb shell pm uninstall -k com.packagename

For example:

adb shell pm uninstall -k com.fedmich.pagexray

The -k flag tells the package manager to keep the cache and data directories around, even though the app is removed. If you want a clean uninstall, don't specify -k.

6
  • 8
    I like this answer better. Because, with this one you will not get the undelete confirmation dialog box.
    – joctee
    Jun 25, 2013 at 15:08
  • 2
    @joctee, So do I but the question specifically said that they didn't want to uninstall using an intent.
    – OrhanC1
    Oct 28, 2013 at 10:40
  • @Lohoris, Have made it work.. make sure you remove the "+" on neverever's answer
    – fedmich
    Dec 27, 2013 at 6:24
  • 34
    @Johnny_D The -k flag tells the package manager to keep the cache and data directories around, even though the app is removed. If you want a clean uninstall, don't specify -k.
    – Yojimbo
    Feb 12, 2014 at 22:44
  • 3
    I keep getting Failure messages when trying to use this command. Aug 1, 2016 at 13:01
178

You can do it from adb using this command:

adb shell am start -a android.intent.action.DELETE -d package:<your app package>
6
  • 2
    can you please tell what -d package:<your app package> stands for? any documentation is there?
    – RPB
    Oct 18, 2012 at 9:10
  • 11
    -d means data. -a means action. You are launching an Intent with action as "Delete", and data as "package:your app package". This will start the activity in charge of uninstalling packages and try to uninstall the package provided in data. Documentation can be found by using "adb shell am" command.
    – pcans
    Oct 18, 2012 at 9:23
  • No, if your app contains an activated DevicePolicyManager, you will have to manually disable it first.
    – pcans
    Jun 24, 2013 at 8:23
  • Above command shows Delete This App confirmation dialog on the phone. Use adb shell pm uninstall -k com.packagename instead.
    – ViliusK
    Jun 21, 2016 at 4:50
  • 2
    This wouldn't work for system apps. The prompt dialog would come up, but the app would not get uninstalled. Aug 1, 2016 at 12:59
12

Using ADB, you can use any of the following three commands:

adb shell am start -a android.intent.action.UNINSTALL_PACKAGE -d "package:PACKAGE"
adb shell am start -n com.android.packageinstaller/.UninstallerActivity -d "package:PACKAGE"
adb shell am start -a android.intent.action.DELETE -d "package:PACKAGE"

Replace PACKAGE with package name of the installed user app. The app mustn't be a device administrator for the command to work successfully. All of those commands would require user's confirmation for removal of app.

Details of the said command can be known by checking am's usage using adb shell am.

I got the info about those commands using Elixir 2 (use any equivalent app). I used it to show the activities of Package Installer app (the GUI that you see during installation and removal of apps) as well as the related intents. There you go.

The alternative way I used was: I attempted to uninstall the app using GUI until I was shown the final confirmation. I didn't confirm but execute the command

adb shell dumpsys activity recents   # for Android 4.4 and above
adb shell dumpsys activity activities # for Android 4.2.1

Among other things, it showed me useful details of the intent passed in the background. Example:

intent={act=android.intent.action.DELETE dat=package:com.bartat.android.elixir#com.bartat.android.elixir.MainActivity flg=0x10800000 cmp=com.android.packageinstaller/.UninstallerActivity}

Here, you can see the action, data, flag and component - enough for the goal.

1
  • I understand that the question is old so my answer may not be much relevant. But it is totally relevant to the Android versions used by majority of users nowadays.
    – user47
    Dec 10, 2015 at 21:03
7

While the above answers work but in case you have multiple devices connected to your computer then the following command can be used to remove the app from one of them:

adb -s <device-serial> shell pm uninstall <app-package-name>

If you want to find out the device serial then use the following command:

adb devices -l

This will give you a list of devices attached. The left column shows the device serials.

7

I assume that you enable developer mode on your android device and you are connected to your device and you have shell access (adb shell).

Once this is done you can uninstall application with this command pm uninstall --user 0 <package.name>. 0 is root id -this way you don't need too root your device.

Here is an example how I did on my Huawei P110 lite

# gain shell access
$ adb shell

# check who you are
$ whoami
shell

# obtain user id
$ id
uid=2000(shell) gid=2000(shell)

# list packages
$ pm list packages | grep google                                                                                                                                                         
package:com.google.android.youtube
package:com.google.android.ext.services
package:com.google.android.googlequicksearchbox
package:com.google.android.onetimeinitializer
package:com.google.android.ext.shared
package:com.google.android.apps.docs.editors.sheets
package:com.google.android.configupdater
package:com.google.android.marvin.talkback
package:com.google.android.apps.tachyon
package:com.google.android.instantapps.supervisor
package:com.google.android.setupwizard
package:com.google.android.music
package:com.google.android.apps.docs
package:com.google.android.apps.maps
package:com.google.android.webview
package:com.google.android.syncadapters.contacts
package:com.google.android.packageinstaller
package:com.google.android.gm
package:com.google.android.gms
package:com.google.android.gsf
package:com.google.android.tts
package:com.google.android.partnersetup
package:com.google.android.videos
package:com.google.android.feedback
package:com.google.android.printservice.recommendation
package:com.google.android.apps.photos
package:com.google.android.syncadapters.calendar
package:com.google.android.gsf.login
package:com.google.android.backuptransport
package:com.google.android.inputmethod.latin

# uninstall gmail app
pm uninstall --user 0 com.google.android.gms
1
  • 1
    --user 0 to perform the delete as root is very useful
    – bw_üezi
    Jan 21, 2020 at 17:16
4

In my case, I do an adb shell pm list packages to see first what are the packages/apps installed in my Android device or emulator, then upon locating the desired package/app, I do an adb shell pm uninstall -k com.package.name.

0

Running the @neverever415 answer I got:

Failure [DELETE_FAILED_INTERNAL_ERROR]

In this case check that you wrote a right package name, maybe it is a debug version like com.package_name.debug:

adb shell pm uninstall com.package_name.debug

Or see https://android.stackexchange.com/questions/179575/how-to-uninstall-a-system-app-using-adb-uninstall-command-not-remove-via-rm-or.

Not the answer you're looking for? Browse other questions tagged or ask your own question.