adb-idea
adb-idea copied to clipboard
Can't Uninstall App if it's set as a Device Administrator
If the app is defined as a device administrator then it's not possible to uninstall it and the message that appears says that the app is not installed on the device, which is not correct.
If possible, it should remove the app from being a device administrator and then attempt to uninstall it.
If not, the error message should be corrected.
Not sure if this will be useful for you, but it's not possible to uninstall a device admin app unless it's declared android:testOnly in the application in its manifest.
Try command adb shell dpm
to check the documentation.
$ adb shell dpm usage: dpm [subcommand] [options] usage: dpm set-active-admin [ --user <USER_ID> | current ] <COMPONENT> usage: dpm set-device-owner [ --user <USER_ID> | current EXPERIMENTAL ] [ --name <NAME> ] <COMPONENT> usage: dpm set-profile-owner [ --user <USER_ID> | current ] [ --name <NAME> ] <COMPONENT> usage: dpm remove-active-admin [ --user <USER_ID> | current ] [ --name <NAME> ] <COMPONENT>
dpm set-active-admin: Sets the given component as active admin for an existing user.
dpm set-device-owner: Sets the given component as active admin, and its package as device owner.
dpm set-profile-owner: Sets the given component as active admin and profile owner for an existing user.
dpm remove-active-admin: Disables an active admin, the admin must have declared android:testOnly in the application in its manifest. This will also remove device and profile owners
There is no option dpm remove-active-admin in documentation.
same issue here
You can unset it programmatically. You need to call this function in your application DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
dpm.clearDeviceOwnerApp(context.getPackageName());
After call dpm.clearDeviceOwnerApp(context.getPackageName());
I still can not uninstall the app. Did you have same issue?
what android api level you are working on ?
try adb shell dpm remove-active-admin ComponentInfo{}
It's not working for me, I have message "my.package.name is already running" and I can't reinstall the app, Install with modified manifest-file or with code DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); dpm.clearDeviceOwnerApp(context.getPackageName());
I can't do anything.
Having the same issue here, was trying to add admin function on my APP but the app becomes impossible to uninstall and the remove-active-admin becomes Error: unknown command
Hi, for me
1- adb shell dpm remove-active-admin [package_name]/.DeviceReceiver
2- if(devicePolicyManager.isDeviceOwnerApp(mContext.getPackageName())) devicePolicyManager.clearDeviceOwnerApp(mContext.getPackageName());
above both options work with all versions of android > 21. i can
- uninstall the app
- remove device admin
- make app again device admin
no issues
i define one property in menifest: android:testOnly="true"
to install app through adb: adb install -t [path of apk]
Can someone help me define android:testOnly="true" in manifest? I have searched everywhere but I couldn't manage to find something.
Can someone help me define android:testOnly="true" in manifest? I have searched everywhere but I couldn't manage to find something.
Add this in application tag
#securityplugin