没有给出存储许可

时间:2018-06-11 14:56:06

标签: react-native react-native-android

我正在试图给一个Android应用WRITE_EXTERNAL_STORAGE,但它似乎没有在模拟器中获得权限。 Android.manifest如下所示:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

如你所见,我清楚android.permission.WRITE_EXTERNAL_STORAGE。任何人都知道为什么还没有给出许可?我尝试了各种模拟器(API 24,26,28)。

任何想法都赞赏。

编辑:我的项目有很多依赖项:

"dependencies": {
    "moment": "^2.22.0",
    "react": "16.0.0",
    "react-native": "0.51.0",
    "react-native-background-timer": "^2.0.1",
    "react-native-camera": "^1.1.4",
    "react-native-code-push": "^5.3.2",
    "react-native-elements": "^0.19.0",
    "react-native-google-analytics-bridge": "^5.6.3",
    "react-native-modal-dropdown": "^0.6.2",
    "react-native-photo-upload": "^1.2.0",
    "react-native-router-flux": "^4.0.0-beta.28",
    "react-native-star-rating": "^1.0.9",
    "react-native-ui-kitten": "^3.0.0",
    "react-native-vector-icons": "^4.5.0",
    "recyclerlistview": "^1.3.1",
    "react-native-wheel-picker": "^2.0.0",
  },

3 个答案:

答案 0 :(得分:1)

我已用PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE)修复了它。

答案 1 :(得分:0)

您是否尝试过设置:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" tools:replace="android:maxSdkVersion" />

取自: WRITE_EXTERNAL_STORAGE not working on lollipop even though it's set in the manifest

甚至是这样:

 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace" />

答案 2 :(得分:0)

Appranetly SDK&gt;即使某些事情被指定,23也需要获得许可。

https://developer.android.com/training/permissions/requesting

private static final int PERMISSION_WRITE_REQUEST_CODE = 1;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {

    if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
            == PackageManager.PERMISSION_DENIED) {

        Log.d("WritePermission", "No write permission given. Requesting...");
         ActivityCompat.requestPermissions(thisActivity,
                new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                PERMISSION_WRITE_REQUEST_CODE);
    }
}