0

Problem

My App.apk is currently set as a custom Launcher and also set as a Device Owner to have access to the Lock Task Mode.

Command to be a Device Owner

adb shell dpm set-device-owner com.package.name/.MyDeviceAdminReceiver

Previous to that I could just press Run App and the old app.apk process would have been killed and the new one would appear.

Now I have to manually reinstall it by pressing build and then using adb

  • adb install -t -r <path/app-debug.apk>

I have already tried the attaching to debugger solution provided here which doesn't work.

According to Googles Issue Tracker this is the reason why it happens.

It looks like we don't recognize when an app features BIND_DEVICE_ADMIN permission which protects them from being force-stoped.

My goal

I don't want to manually write adb install I want to achieve the same fluent workflow without this workaround stuff. Pressing Run App should have the same effect as before.

Im pretty confident there is a custom run configuration that can help with this problem but this is my first android project so any ideas or help would be appreciated.

What I have tried

I tried to setup a before launch shell script on the Run/Debug configuration but all adb commands are not working to stop my app.

  1. adb shell pm disable com.package.name

    Security exception: Cannot disable a protected package: com.package.name

  2. adb uninstall com.package.name

    Failure [DELETE_FAILED_DEVICE_POLICY_MANAGER]

Ojav
  • 678
  • 6
  • 22

1 Answers1

0

I have created custom gradle task in run configurations which installs app on my managed device.

I used gradle task installDebug. You might need use other tasks but this one work perfectly for me.