How to remove an app with active device admin enabled on Android?

AndroidUninstallationDevice Admin

Android Problem Overview


I wrote an app with device admin enabled (DevicePolicyManager) and installed. But when I want to uninstall it, it returns failed with this message

> WARN/PackageManager(69): Not removing package com.mypackage.test: has active device admin

How can I uninstall it, or uninstall it programmically? Thanks.

Android Solutions


Solution 1 - Android

Go to SETTINGS->Location and Security-> Device Administrator and deselect the admin which you want to uninstall.

Now uninstall the application. If it still says you need to deactivate the application before uninstalling, you may need to Force Stop the application before uninstalling.

Solution 2 - Android

You could also create a new DevicePolicyManager and then use removeAdmin(adminReceiver) from an onClickListener of a button in your app

//set the onClickListener here
{
   ComponentName devAdminReceiver = new ComponentName(context, deviceAdminReceiver.class);
   DevicePolicyManager dpm = (DevicePolicyManager)context.getSystemService(Context.DEVICE_POLICY_SERVICE);
   dpm.removeActiveAdmin(devAdminReceiver);
}

And then you can uninstall

Solution 3 - Android

On Samsung go to "Settings" -> "Lock screen and security" -> "Other security settings" -> "Phone administrators" and deselect the admin which you want to uninstall.

The "security" word was hidden on my display, so it was not obvious that I should click on "Lock screen".

Solution 4 - Android

> Redmi/xiaomi user

Go to "Settings" -> "Password & security" -> "Privacy" -> "Special app access" -> "Device admin apps" and select the account which you want to uninstall.

Or Simply

go to setting -> Then search for Device admin apps -> click and select the account which you want to uninstall.

Solution 5 - Android

Enter vault password and inside vault right top corner options icon is there. Press on it. In that ->settings->vault admin rites to be unselected. Work done. U can uninstall app now.

Solution 6 - Android

For Redmi users,

Settings -> Password & security -> Privacy -> Special app access -> Device admin apps

Click the deactivate the apps

Solution 7 - Android

If you known the package name,with abd you can remove the device owner

adb shell dpm remove-active-admin packagename/.yourAdminReceiver

then

adb uninstall packagename

Solution 8 - Android

On a Samsung Galaxy S9 with Android 10 and One UI 2.0: Biometrics and security -> Other security settings -> Device admin apps.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionshiamiView Question on Stackoverflow
Solution 1 - AndroidAtmaramView Answer on Stackoverflow
Solution 2 - AndroidReedView Answer on Stackoverflow
Solution 3 - AndroidraacerView Answer on Stackoverflow
Solution 4 - AndroidSrikrushnaView Answer on Stackoverflow
Solution 5 - AndroidNatendraView Answer on Stackoverflow
Solution 6 - AndroidRajanView Answer on Stackoverflow
Solution 7 - AndroidfangxingView Answer on Stackoverflow
Solution 8 - AndroidFranck DernoncourtView Answer on Stackoverflow