I\'m trying to uninstall an application from shell, however this application is running as a device administrator and thus shell> adb uninstall com.example.test
"adb shell pm disable-user pkgname" will deactive DeviceAdmin and freeze the app. It will not be active again even if you enable the app.
(Tested on Samsung Galaxy S7 with 8.0 Oreo)
Typically, administrative access is revoked via the Device Administrators screen, then the app is uninstalled. In the subsequent examples, I'll assume airdroid (com.sand.airdroid
), has been configured as a device administrator, and is to be uninstalled. So to tailor this example, replace instances of com.sand.airdroid
with your own app name.
To access Device Administrators, navigate: Settings → Security → Device Administrators. Then, uncheck the application to un-set administrative access for.
It's also possible to open up this activity using the shell:
adb shell am start -S "com.android.settings/.Settings\$DeviceAdminSettingsActivity"
Once this is done, the activity can be uninstalled normally:
adb uninstall com.sand.airdroid
A brute-force method does exist. It involves searching for all files in the /system and /data filesystems, and deleting each found item. Disclaimer: Use with care (test on an emulator first).
adb shell
# Switch to root
su -
# Search for all installed files using the fully-qualified app name
find /system /data -name \*com.sand.airdroid\*
...a list of files (including directories) appears -- for each file, cause it to be deleted by prefixing it with a rm -f
:
rm -r /data/media/0/Android/data/com.sand.airdroid
rm -r /data/data/com.sand.airdroid
rm -r /data/app-lib/com.sand.airdroid-1
rm -r /data/app/com.sand.airdroid-1.apk
rm -r /data/dalvik-cache/data@app@com.sand.airdroid-1.apk@classes.dex
# Run the find command again to ensure nothing was missed
find /system /data -name \*com.sand.airdroid\*
# exit root
exit
# exit Android shell
exit
To allow Android to clean up its files, reboot the device.
adb reboot
Once the device has restarted, the application can be uninstalled with the uninstall
command to finalize clean-up.
adb uninstall com.sand.airdroid
You can not uninstall app directly if it is set as Admin .first you have to disable the admin mode then you will be able to uninstall app. to remove active admin first you run this command
adb shell dpm remove-active-admin com.kiosk.example/com.kiosk.example.MyDeviceAdminReceiver
(com.kiosk.example) is package name replace it with your own and MyDeviceAdminReceiver is receiver name. when this command give success then you can uninstall app. or run this command to uninstall
adb uninstall com.kiosk.example
.