Rolf ツ Rolf ツ - 1 month ago 25x
Android Question

How to debug Android 6.0 permissions?

While migrating one of my apps to use the Android 6.0 permissions system, I found it very hard to debug permissions using the emulator.


  • Disabling a permission in the app info screen doesn't re-show the grant permission dialog when using the

  • Reinstalling the app seems to be the only way to make the app show the grant permission dialog again.

What is the proper method to debug permission using the Android emulator?


It’s actually very easy to debug Android 6.0 permissions. You can reset the permissions to the 'install state' for the current foreground app using the following ADB shell command:

adb shell pm reset-permissions

For a specific package:

adb shell pm reset-permissions com.your.package

You can easily execute this command using the terminal interface in Android Studio. Note that the ADB command only works if the ADB directory is added to the path system environment variable (see: add ADB to path variable).

You can also reset/revoke a specific permissions using:

adb shell pm revoke com.your.package android.permission.WRITE_EXTERNAL_STORAGE

A downside of this command is that it will restart your app. To grant a permission replace revoke with grant.