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?

Alex P.
  • 30,437
  • 17
  • 118
  • 169
RPB
  • 16,006
  • 16
  • 55
  • 79

7 Answers7

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.

thumbmunkeys
  • 20,606
  • 8
  • 62
  • 110
neverever415
  • 2,277
  • 1
  • 11
  • 2
  • 8
    I like this answer better. Because, with this one you will not get the undelete confirmation dialog box. – joctee Jun 25 '13 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 '13 at 10:40
  • @Lohoris, Have made it work.. make sure you remove the "+" on neverever's answer – fedmich Dec 27 '13 at 06:24
  • Does this way of deletion also deletes settings and cache? Or it simply deletes app. – Johnny_D Feb 10 '14 at 11:02
  • 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 '14 at 22:44
  • 3
    I keep getting **Failure** messages when trying to use this command. – IgorGanapolsky Aug 01 '16 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>
pcans
  • 7,611
  • 3
  • 32
  • 27
  • 2
    can you please tell what -d package: stands for? any documentation is there? – RPB Oct 18 '12 at 09: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 '12 at 09:23
  • No, if your app contains an activated DevicePolicyManager, you will have to manually disable it first. – pcans Jun 24 '13 at 08:23
  • Above command shows Delete This App confirmation dialog on the phone. Use `adb shell pm uninstall -k com.packagename` instead. – ViliusK Jun 21 '16 at 04:50
  • @ViliusK I'm sure that's what Rinkal wanted, the popup to show up after the command. – auhmaan Jul 04 '16 at 16:40
  • 2
    This wouldn't work for system apps. The prompt dialog would come up, but the app would not get uninstalled. – IgorGanapolsky Aug 01 '16 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.

user47
  • 1,080
  • 11
  • 28
  • 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 '15 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.

Syed Ali
  • 1,817
  • 2
  • 23
  • 44
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
Lukasz Dynowski
  • 11,169
  • 9
  • 81
  • 124
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.

warfreak92
  • 324
  • 4
  • 15
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.

CoolMind
  • 26,736
  • 15
  • 188
  • 224