pbreault / adb-idea

A plugin for Android Studio and Intellij IDEA that speeds up your day to day android development.
Apache License 2.0
2.1k stars 256 forks source link

Can't Uninstall App if it's set as a Device Administrator #77

Open filipesilvapt opened 6 years ago

filipesilvapt commented 6 years ago

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.

RGU5Android commented 6 years ago

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 | current ] usage: dpm set-device-owner [ --user | current EXPERIMENTAL ] [ --name ] usage: dpm set-profile-owner [ --user | current ] [ --name ] usage: dpm remove-active-admin [ --user | current ] [ --name ]

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

mushahidgillani commented 6 years ago

There is no option dpm remove-active-admin in documentation.

ysyyork commented 6 years ago

same issue here

mushahidgillani commented 6 years ago

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());

passos commented 5 years ago

After call dpm.clearDeviceOwnerApp(context.getPackageName()); I still can not uninstall the app. Did you have same issue?

mushahidgillani commented 5 years ago

what android api level you are working on ?

fireb86 commented 3 years ago

try adb shell dpm remove-active-admin ComponentInfo{}

kirkaDev commented 2 years ago

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.

ZikeWangTamato commented 2 years ago

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

ABNG commented 2 years ago

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

no issues

i define one property in menifest: android:testOnly="true"

to install app through adb: adb install -t [path of apk]

dnzumrk commented 1 year ago

Can someone help me define android:testOnly="true" in manifest? I have searched everywhere but I couldn't manage to find something.

mushahidgillani786 commented 1 year ago

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

ceatechsolutios commented 5 months ago

IMG_20240117_105733 #securityplugin