How to manage Runtime permissions android marshmallow espresso tests

后端 未结 12 918
孤独总比滥情好
孤独总比滥情好 2020-12-05 02:33

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

12条回答
  •  攒了一身酷
    2020-12-05 03:25

    adb install -g package.apk

    I had a similar issue in automated testing: when launching the app the permission dialog popped up. The adb shell pm grant … command did not help but there is the -g option of adb install to grant all permissions upon install. This solved the problem for me.

    From adb --help:

    Android Debug Bridge version 1.0.41
    Version 30.0.5-6877874
    […]
    app installation (see also `adb shell cmd package help`):
     install [-lrtsdg] [--instant] PACKAGE
         push a single package to the device and install it
    […]
        -g: grant all runtime permissions
    […]
    

提交回复
热议问题