API 26+: WRITE_EXTERNAL_STORAGE permission is always denied

前端 未结 2 647
野趣味
野趣味 2020-12-14 02:18

I have switched my app to target API 27 and now it can\'t be granted WRITE_EXTERNAL_STORAGE permission -- grantResult is always -1.

2条回答
  •  臣服心动
    2020-12-14 02:55

    Somewhere along the line, you are picking up that android:maxSdkVersion="18" attribute. My guess is that it is coming from a library. Check the "Merged Manifest" tab in Android Studio, when you are editing your own manifest. It will have details of what is contributing the various elements and attributes.

    android:maxSdkVersion has the effect of removing your element on higher Android SDK versions, at least in terms of how runtime permissions work.

    Since you need this permission for all versions, adding tools:remove="android:maxSdkVersion" on the element should revert the android:maxSdkVersion="18" and give you what you expect.

提交回复
热议问题