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
did not work.
How can I disable a device admin from shell?
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@[email protected]@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
adb shell pm disable-user (package name)
will deactivate DeviceAdmin and disable the app. It will not be activated even if you enable the app again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With