AndroidManifest in androidTest directory being ignored

前端 未结 6 2052
一整个雨季
一整个雨季 2020-12-05 06:52

I\'m trying to test using the following directory structure (which was setup by Android Studio):

\"test

6条回答
  •  鱼传尺愫
    2020-12-05 07:25

    As specified here, during instrumented tests, there are generated two .apk files. If you take a look, the smaller one it's most probably the one named app-debug-androidTest-unaligned.apk and it actually does include the provided permissions.

    Inspecting the file with aapt d permissions .apk can be useful to see a list of all of them.

    Now, there might be an issue with the context itself where the permission is requested. I had a similar problem, trying to write some screenshots on SD card (thus needing the WRITE_EXTERNAL_STORAGE permission).

    This answer helped me to fix the problem, although I cannot fully understand why it's necessary.

    In few words, you'll need to declare the same android:sharedUserId in both manifests, in order to merge the permissions when both apks are installed on the same device - that happens when tests are running. This helped me to separate permissions needed just for testing from the one in production.

提交回复
热议问题