96

I am writing some sample apps.
After I debug these apps, I don't see an uninstall button in my device's application management.
When I do adb uninstall, it always says Failure without any reason.
In DDMS I saw that my apk is stored in /data/app/com.k2g.leaveDemo-1.apk.
I am not sure what am I missing.
I always have to reset my device to get rid of these apps :(

Do I need to do sign something?
Do I need to do something in debug mode?
Or does it depend on the version?

I am using Samsung S2.

user1848385
  • 989
  • 1
  • 7
  • 8
  • 1
    what is your uninstall command you are running? – Bobbake4 Nov 23 '12 at 19:44
  • i m running "adb uninstall com.k2g.leaveDemo" – user1848385 Nov 23 '12 at 19:45
  • That should be fine as long as you only have one android device including emulators running. If you have more than one you will have to add another switch to indicate which device you would like to run the command on. Also make sure the package name defined in your apps manifest is "com.k2g.leaveDemo". – Bobbake4 Nov 23 '12 at 19:48
  • yes, i have only one device attached to adb. I suspect, it has something to do with signing or basic app development as all my apps are behaving the same way. If you think I am missing some settings needs to be done in menifest, please let me know. I am looking in DDMS and it says the same package name , so package name is correct in menifest. – user1848385 Nov 23 '12 at 19:52
  • Does your device allow you to enable installation of third-party apps? If not, you should do your debugging on an emulator only. – Ted Hopp Nov 23 '12 at 19:52
  • It does, I have installed many custom build apps on this device and all are working fine. But only it is not uninstalling:( – user1848385 Nov 23 '12 at 19:57
  • In my case, my apk had space in it's filename. Renaming it resolved my problem. – Sonal Aggarwal Oct 04 '15 at 19:31
  • -- Simple just remove the application from device manager & then try .. you got the success.. – Zala Janaksinh Nov 11 '16 at 07:19
  • according http://stackoverflow.com/questions/38450717/session-app-error-while-installing-apk#answer-42617107 , try to disable 'instant run' . worked for me! – Saeid Mar 12 '17 at 19:34
  • https://www.xda-developers.com/uninstall-carrier-oem-bloatware-without-root-access/ – Dženis H. Apr 07 '20 at 23:05

24 Answers24

114

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>. Where 0 is ID of main user in Android system. This way you don't need to root your device.

Here is an example how I did on my Huawei p10 lite device.

# 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 google play services (warning: take backup first!)
pm uninstall --user 0 com.google.android.gms
Ganesh Mohan
  • 1,027
  • 10
  • 18
Lukasz Dynowski
  • 11,169
  • 9
  • 81
  • 124
  • Thank you. Saved a phone from a viruses – Taras Vovkovych Dec 29 '18 at 20:58
  • 7
    Thanks, I forgot the ```--user 0``` option. – Lalylulelo Jan 16 '19 at 21:21
  • 10
    `adb shell pm uninstall --user 0 com.facebook.` – AutonomousApps Mar 12 '19 at 04:57
  • Can't do this on my Alcatel. They don't allow the horrible bloatware apps to be removed. – hat Jul 23 '19 at 06:44
  • Does `--user 0` correspond to the root user? – Abhijit Feb 21 '20 at 23:18
  • 1
    @Abhijit The short answer is yes. In Unix and Linux, any account with user id 0 is a root account. – Lukasz Dynowski Feb 23 '20 at 07:51
  • 1
    I sometimes get the message `Failure - not installed for 0` – Harsha Jun 15 '20 at 18:52
  • 1
    Not in this situation. User id 0 is main user in Android system, it has nothing to do with Unix user id 0 which is root. – QkiZ Dec 13 '20 at 17:01
  • Thanks @QkiZ I was convinced that 0 was ID of root user, since root ID in Unix system is 0. – Lukasz Dynowski Dec 13 '20 at 19:23
  • 1
    There's two types of users in Android. First is actual user that you configure in system UI. You can have few users in Android settings, every of these users have personal files, settings and apps. You can switch interface between these users. First user that configure device has 0 id and that's why these commands from answer is referring to. Second type of users is a Unix users because Android is using Linux as a base. These users aren't accessible to normal user when device isn't rooted. Every app in system is different user. – QkiZ Dec 14 '20 at 00:32
  • You can uninstall apps with pm command and --user 0 option on unrooted device, which means that you can't use root (id 0 Unix user). – QkiZ Dec 14 '20 at 00:36
  • Oh, Thank You for the math! It only works for me. You are my lifesafer. – Serg Burlaka Jan 15 '22 at 17:20
56

Yes, mobile device management would bring its own problems, but i bet 'Failure' is a dos2unix problem. On my Linux machines, adb is appending a DOS newline which causes 'Failure' because uninstall thinks the CR character is part of the package name. Also remove '-1.apk' from the end of the package-1.apk filename.

adb root
adb shell
pm list packages
pm uninstall com.android.chrome

In my case, i have a phone that is in permanent 'Safe mode' so only apps under /system/app/ have a chance of running. So i install them to get the .apk files copied off, then uninstall in bulk and copy to /system/app/, wipe the /cache and reboot. Now i have more apps running even though in safe mdoe.

# adb root
# pm list packages -3 > /root/bulkuninstall.txt
# vi /root/bulkuninstall.txt  and check ^M characters at end of each line.   
   If ^M, then must run dos2unix /root/bulkuninstall.txt.  
   Remove '-1.apk' using vi search and replace:  
        :%s/-1\.apk//g 
   Or sed...

# cp /data/app/* /storage/sdcard1/APKs/
# for f in `cat /root/bulkuninstall.txt`; do echo $f; pm uninstall $f; done;
# 
# echo Now remount system and copy the APK files to /system/app/
# mount | grep system
# mount -o remount,rw /dev/block/(use block device from previous step)  /system 
# cp /storage/sdcard1/APKs/* /system/app/
# reboot

wipe cache power on.

Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
rjt
  • 1,042
  • 10
  • 16
39

This is not an exact answer, but if you're looking to uninstall the app because you have an updated .apk to install, you can try this:

adb install -r yourapp.apk

The -r option tells adb to reinstall the app

António Almeida
  • 9,620
  • 8
  • 59
  • 66
edg
  • 659
  • 6
  • 13
  • 2
    It doesn't answer the question but it's what I was after eventually. – user276648 Oct 05 '16 at 10:17
  • 2
    I get the following error message: package com.google.android.GoogleCamera signatures do not match the previously installed version; ignoring! – egalot Oct 01 '17 at 19:44
23

If it is an Android internal app you may need to:

  • adb shell
  • mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
  • rm /system/app/your_app
  • rm /data/data/your_app
  • remove any entries in /data/system/packages.xml
  • remove any entries in /data/system/packages.list
  • edit AndroidManifest.xml and get rid of android:sharedUserId="android.uid.shared"

This is at your own risk;-|, try in emulator first...

Maarten
  • 9
  • 4
powder366
  • 4,351
  • 7
  • 47
  • 79
21

Just run ADB and use the following command:

adb shell pm uninstall -k --user 0 <package name>

And you should get this return:

successful
Robert
  • 6,855
  • 4
  • 35
  • 43
Matthew Farmer
  • 211
  • 2
  • 3
  • 2
    What if I don't get 'successful' in return? I got Failure [INSTALL_FAILED_INVALID_APK: Missing existing base package for null] – Binu Jasim Oct 16 '21 at 08:17
11

okey I was in same situation I tried all of this without result.. and the last answer was close.. I got it doing the follow:

in order to get the right name of your package do the follow:

adb shell pm list packages | grep "name of your app here"

you should see the right name of your app.. so now this one just works:

adb uninstall com.your-real-app-name

finally the command run works again:

ionic run android
bySamo
  • 475
  • 5
  • 12
  • 1
    This worked for me. I think it must have been a case sensitivity issue for me. Also, if I changed the case of some characters in the package, then adb install -r would also fail for these apks, since the case of the package on the device did not match the case in the manifest of the APK I was trying to install. – Wayne Uroda Oct 31 '17 at 06:29
  • 1
    Worked for me too. – borizzzzz Jul 16 '18 at 12:38
  • 1
    Thanks to your answer I found that my package de.some-thing.app had been renamed on the device to de.some_thing.app. Delete with the later name worked fine. – Marvin Nov 22 '19 at 10:06
9

Seems like you have an app that contains a hidden Device Administrator like this one here: http://www.symantec.com/security_response/writeup.jsp?docid=2013-060411-4146-99

you can only uninstall such an app when you disable the device admin first. You can use https://play.google.com/store/apps/details?id=com.trendmicro.mtrt.hiddenDAcleaner to disable it or do it by your own by sending the intent to the app that invokes the receiver that will disable the device admin.

reox
  • 5,036
  • 11
  • 53
  • 98
  • 1
    Thank you so much! I had a device admin that bricked my phone and I couldn't do anything without it popping up allll the time. Disabling it as an admin let me uninstall it. THANK YOU SOOO MUCH!! – Joshua G May 20 '14 at 19:21
9

I find that adb shell pm uninstall <package> works consistently, where adb uninstall <package> does not.

Christopher Pickslay
  • 17,523
  • 6
  • 79
  • 92
7

Try disable "Instant run" from settings window

no_cola
  • 1,150
  • 8
  • 7
4

Maybe you're trying to uninstall an app that is a phone administrator.

To be able to uninstall it, go to Seetings > Security > Phone Administrators. If the app is listed, uncheck it and confirm the operation.

After that, you should be able to uninstall it using the App settings area or adb.

3

Open your application Manifest and check the application's package first.

After that, be sure that your device is set into debugger mode.

Check if ADB can interact with your device:

adb devices

If your device is listed, then run:

adb uninstall PACKAGE_WRITTEN_IN_MANIFEST

noni
  • 2,927
  • 19
  • 18
  • I have tried all these options, everything is perfect but still problem persists. – user1848385 Nov 23 '12 at 19:55
  • The only option that cannot let you uninstall your apps, is mounting the system partition as writable,installing your apks on system/app, and remounting again as read only. Did you do that? – noni Nov 23 '12 at 19:58
  • I have not done any such steps. I could see my apk file in /data/app folder so i m sure it is not considering this as system app as well. – user1848385 Nov 23 '12 at 20:00
  • Try this: adb shell @ENTER@ cd /data/app @ENTER@ rm com.k2g.leaveDemo-1.apk @ENTER@ exit @ENTER@ adb reboot @ENTER@ don't put @ENTER@ on your cmd, just press enter key – noni Nov 23 '12 at 20:02
  • Can any MDM(mobile Device mgmt) app restrict option of uninstall? – user1848385 Nov 23 '12 at 20:09
2

You should have to manually delete apps. got to Setting-> Application Management -> Running application, tap on it and you can remove, stop apps from there.

Anam Akram
  • 59
  • 7
  • 2
    Probably going to "Downloaded applications" is better than "Running applications"; the app may not be running. – Ted Hopp Nov 23 '12 at 19:47
  • all those options are greyed out. I can't tap any button. "Uninstall", "Clear Data", clear cache" all are disabled. – user1848385 Nov 23 '12 at 19:48
2

This worked for me:

This is the directory where all the APKs are stored:

cd /system/app

List them:

ls

Choose one to remove.

pm install -r <app_to_remove>.apk

Example:

$ pm install -r Google-Play-services.apk
        pkg: Google-Play-services.apk
Success


I noticed that I get failure if the application I'm trying to remove is running, so kill it first.

Also, I noticed you might have to run (on a rooted device):

$ su
# mount -o remount +rw /
Geremia
  • 4,745
  • 37
  • 43
1

I had a instance of an emulator running and a device connected.

When I ran command `adb -d uninstall PACKAGE_NAME', I got an error 'DELETE_FAILED_INTERNAL_ERROR' but when I killed the Emulator instance, I got a 'success' in un-installation process.

Codelearner
  • 241
  • 2
  • 3
  • 16
1

In my case I often get this issue when I first complise a app in debug mode and later try to install the google signed app.

That is because both apps have the same package name but diffent signatures. Since I upgraded to Android lollypop I sometimes even get this error if I uninstall the app via the settings\Apps. If you have this problem check if the app is installed in a other User profile and uninstall it in all user accounts.

Radon8472
  • 4,285
  • 1
  • 33
  • 41
1

If you have problems uninstalling through adb, I can recommend the following tool:

https://github.com/patrickfav/uber-adb-tools

you can use wildcards and supports multiple devices, also has some better error handling than the vanilla ADB (but uses it in background of course). Will work on your platform.

console showcase

Full disclaimer: I am the developer

Patrick
  • 33,984
  • 10
  • 106
  • 126
0

Make sure you enter the full package name with application name:

com.domain.app
powder366
  • 4,351
  • 7
  • 47
  • 79
0

You have the name of the apk and not the package name: You should first know the package name. Fot this tape:

adb shell pm list packages

Once you have the package name (be carefull, package name is like com.intel.... and not package:com.intel...), tape:

adb shell pm uninstall -k "package_name"

and Bingo!

matdev
  • 4,115
  • 6
  • 35
  • 56
0

It can be something as simple as typing the package name in the wrong case...

I had the same problem - turned out I was entering the package name in all lower case when the actual package name included upper case characters.

adb uninstall -k <packageName - eg. com.test.app>

( If you're explicitly uninstalling you probably don't want the -k which keeps the app data and cache directories around. )

Bob
  • 1,589
  • 17
  • 25
  • 1
    Failure [DELETE_FAILED_DEVICE_POLICY_MANAGER] – Radu Dec 04 '17 at 13:06
  • @Radu. This answer only addresses one possible and trivial issue - so trivial it might be over-looked. Your situation sounds like you have a non-standard/typical device configuration - possibly policy set by an admin (company ?) agent or what you're trying to remove is otherwise system protected in some way. Can't help you as I don't know what the error covers. – Bob Dec 04 '17 at 17:01
0

You can follow below steps to uninstall the app from the device via command prompt.

  1. execute the command : adb -s [devicename] uninstall -k [packagename]. this command will retain the data and cache in the device but will remove the app from the device.
  2. To remove the data and cache also from the device along with the application execute the command below. adb shell pm uninstall -k [packagename].

if it shows sucess your app is uninstalled successfully'

divaPrajapati09
  • 170
  • 1
  • 12
0

If You use Xiomi Device then You need to Login in MI Account.

After Successful Registration you can install and Uninstall via ADB.

Pinak Gauswami
  • 789
  • 6
  • 10
0

In my case this was happening because I was trying to uninstall the wrong APK. I didn't realize that my bundleId had appended .demo to the ID.

BlackHatSamurai
  • 23,275
  • 22
  • 95
  • 156
-1

I had a failure when using adb shell uninstall com.package.app/

removed / (so adb shell uninstall com.package.app) and it works

-1

Try disable "Instant run" from Preference! It's working for me.

enter image description here

Jamil Hasnine Tamim
  • 4,389
  • 27
  • 43