I\'m using espresso for testing but sometimes I try to get an image form external storage and with marshmallow I need a Runtime permission otherwise there will be an Excepti
In the multi-flavor setup, whatever your instrumentation task is, let's say connectedYourFlavorDebugAndroidTest, you may specify the permissions you want to have granted before the tests are run on all the connected devices:
gradlew grantYourFlavorDebugPermissions -Ppermissions=android.permission.ACCESS_FINE_LOCATION,android.permission.ACCESS_COARSE_LOCATION
See sfjava's snippet below to copy into build.gradle to generate grantYourFlavorDebugPermissions task