I've run the command adb
adb shell pm path com.some.someapplication --user 10
but it returns in no result.
Possibly, UserID in your case isn't 10. I had the same problem. This is how you can solve :
Run adb shell pm list users You will get an output in the format UserInfo{0:Owner:c13} running
UserInfo{999:XSpace:801010} running
Then use the number in the second user curly braces as the user_id, here it's 999 adb shell pm list packages --user user_id
Once you know the package name, you can use
adb shell pm path com.some.someapplication --user user_id
to pull apk using the package name.
Example: For linkedin installed in work profile , I use
adb shell pm path com.linkedin.android --user 999
Related
I'm dealing with a pretty major malware issue on an Elite 6.0L+ Sky Device. I'm working with a fellow from the malware bytes forums trying to get it cleaned out. I'm trying to uninstall a few apps through adb via command prompt but it's throwing errors.
adb pm shell pm uninstall com.wouzee.hispanopost
That command throws the error:
Failure [DELETE_FAIL_INTERNAL_ERROR]
If I try it as
adb pm shell -k --user 0 uninstall com.wouzee.hispanopost
Then is throws: Failure [no installed for 0]
I have managed to uninstall other things using these commands but the two things I've been told to remove both throw these same errors when I try to remove them.
Does anyone have any idea how to get around this?
I was having the same problem uninstalling with:
adb shell
pm uninstall <package>
This is what worked for me eventually:
adb shell
pm uninstall --user 0 <package>
Some Apps are prevented from uninstalling. You can disable them instead. Use following command on adb shell:
pm disable-user --user 0 <package>
Here is my solution, I uninstall some system apps come up with [DELETE_FAIL_INTERNAL_ERROR] too
use adb shell su to enter shell mode
then using pm uninstall --user 0 <your-pkg-name> to uninstall
PS: if only use adb shell my situation will generate error too, the su is the key to solve problem
What i want
I want to remove some google Apps with a shell script, started from my windows client using adb.
What is the problem
When I use following command in command prompt using adb / shell it works.
pm uninstall --user 0 com.google.android.apps.maps
But when I put the same command into a shell script, push it to my phone and try to run it - it gives the app is not installed error!
I solved the problem with a little workaround.
I just start the pm uninstall command also from the batch and do not push it to the device.
Like this: (uninstall.bat)
adb shell pm uninstall --user 0 com.google.android.gm
adb shell pm uninstall --user 0 com.google.android.apps.maps
adb shell pm uninstall --user 0 com.google.android.youtube
pause
The script you created on your Windows system contains MS-DOS/Windows style newlines (i.e. \r\n). Android shell uses Linux style newlines (\n). So your script gets an extra \r character at the end of every line and your
pm uninstall --user 0 com.google.android.apps.maps becomes pm uninstall --user 0 com.google.android.apps.maps\r.
Your script tries to uninstall a package named com.google.android.apps.maps\r - which does not exist.
To fix the issue you need to remove all those \r from your script after pushing it to the phone using sed -i 's/\r$//' script.sh command for example.
What's the difference between installing an app using the install command and using the package manager's pm install command? Do they do the exact same job? Does one command actually call the other in the back?
adb install -r APK_FILE
adb shell pm install APK_FILE
adb install is a command to run from a development host, which uploads a package somewhere temporary and then installs it.
pm install is a command to run locally on the device.
adb does indeed utilize the pm program on the device - see the source code at
https://android.googlesource.com/platform/system/core/+/kitkat-mr2.2-release/adb/commandline.c
I've to install an android app with package name like "com.xyz.game" using adb.
I want to automate the process using shell script. The process will be like if app is already installed, uninstall it(with command adb uninstall com.xyz.game) and install using "adb install game.apk" otherwise simple "adb install game.apk".
How can I achieve this?
[Update 2]
Without using grep
adb shell pm list packages [your.package.name] as mentioned in the below answer
[Update]
According to (also) correct answer below, try grep the result from pm list packages.
adb shell pm list packages | grep com.your.app.package
[Original]
If the application is already installed and if you try to install the same app again, adb will return with an error - Failure [INSTALL_FAILED_ALREADY_EXISTS]. However, if you want to re-install the already installed app, then use -r parameter.
Ex:
adb install -r game.apk
Try grep the result from pm list packages.
adb shell pm list packages | grep com.xyz.game
You may see the result if already installed.
package:com.xyz.game
No need to use grep. Using following commands you can simply check if application is already exist or not.
Run ADB command
adb shell pm list packages [your.package.name]
If app is already installed then above command will return,
package:[your.package.name]
Else it won't return anything i.e. empty String.
Android 7.0 has introduced cmd (a new native code based) tool which allows to interact with Android services like PackageManager much faster than the old java bytecode based tools like pm. So for recent Android versions instead of adb shell pm list packages <package.name.substring> you should use
adb shell cmd package list packages <package.name.substring>
Taking into account #Joel answer, just do it in one-liner
# uninstall only if exists
adb shell pm list packages | grep com.your.app.package && adb uninstall com.your.app.package
Use First adb shell command if you are using adb otherwise you can use use root in same device by su command
Then, we can get path of installed apk files by their pkg names lets say in our case pkg name is com.tencent.ig
pm path com.tencent.ig | sed 's/package://'
If app installed : You will get the path to the apk file
If app not installed : You will get nothing
Previous answers are limited but by using above logic we can also use if statement easily like :
pkg=com.tencent.ig #Add pkg of your app only here
if [ -f $(pm path $pkg | sed 's/package://') ]
then
echo "YES, app is installed"
#further commands if app is installed
else
echo "NO, app is not installed"
#further commands if app not installed
fi
I think that will be much handy.
This works fine :
adb shell pm list packages your.package.name
Replace your.package.name with the required package name.
If app installed : You will get the path to the apk file
If app not installed : You will get nothing
I can uninstall an app on the device from my computer using adb uninstall <package_name>,
but I'd like to do the same with a script on the actual device.
I've also tried running an android.intent.action.DELETE intent using am but it prompts the user for confirmation.
Given that the device is rooted, is it possible to run a command on the device to uninstall an app without requiring user action/confirmation ?
Trying using the pm command:
pm uninstall <package_name>
or
pm uninstall -k <package_name>
The -k flag keeps the data and cache directories after the package is removed.
I haven't tested this myself, but I don't think this should show a warning message.
To forcefully uninstall the system user apps:
Use:
adb shell pm uninstall --user 0 <package_name>
adb shell pm uninstall *your.package.name*
Did the trick for me.
And if you want to re-install back package removed for a user (i.e. pm uninstall --user 0), without root:
pm install --user 0 $(pm dump <package name> | awk '/path/{ print $2 }')
This will locate .apk of the uninstalled package: pm dump <package name> and search for a line starting with path: to obtain path to the .apk (note that pm path <package> won't work for an uninstalled app) and install it using pm install --user 0 (note that pm install without --user argument wont' work).
This works for any system app, this is a good alternative to pm disable-user <package> which still allows you to easily enable app back via Settings.
For example, you could uninstall Play Store (pm uninstall --user 0 com.android.vending) and have no way to enable/install any application on default non-rooted device without access to adb or pm.
Some Apps can't be uninstalled,so below command gives the error:
adb shell pm uninstall package_name
Failure [DELETE_FAILED_INTERNAL_ERROR]
Try to run disable command instead,
adb shell pm disable package_name
Package package_name new state: disabled
I had fail on uninstall some system launchers (for example NovaLauncher)
In this case I recommend to use "disable" instead "uninstall":
pm disable <package_name>
In result you hide this system launcher (sys app) from list of launchers when you have a few launchers
Simple command to remove any app from the device, try this:
pm uninstall --user 0
This command will forcefully remove that app from the device.
If you have an rooted android device then you can easily uninstall pre-installed apps from your device. My OnePlus device is rooted with Magisk manager.
Rooting an Android device gives you admin privileges towards your device and so you can easily install or uninstall any system application.
However, command line method also works most of the time. I have tested adb method on MIUI device for removing bloatware.
You can follow stackoverflow read this thread....
ADB command: pm uninstall -k <package_name>
Trying using the adb command:
adb uninstall <package-name>
make sure your device is connected