ImagePicker错误:在React本机版本0.59.9和0.59+中未授予权限

时间:2019-07-15 09:06:20

标签: android react-native react-native-image-picker

我根据他们的文档使用的版本为{0.28.1的react-native-image-picker},我认为我根据我的react-native版本使用的是正确的图像选择器版本。 还在AndroidManifest.xml中添加了权限,但是却出现错误“ ImagePicker错误:未授予权限”

没有解决方案。 请帮助。提前谢谢。

package.json

  "dependencies": {
  "jetifier": "^1.6.3",
  "react": "16.8.3",
  "react-moment": "^0.9.2",
  "react-native": "0.59.9",
  "react-native-gesture-handler": "^1.3.0",
  "react-native-image-picker": "^0.28.1",
  "react-navigation": "^3.11.0"
},
"devDependencies": {
  "@babel/core": "^7.4.5",
  "@babel/runtime": "^7.4.5",
  "babel-jest": "^24.8.0",
  "jest": "^24.8.0",
  "metro-react-native-babel-preset": "^0.54.1",
  "react-test-renderer": "16.8.3"
},

android / build.gradle

    ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 16
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "28.0.0"
}

node_modules \ react-native-image-picker \ android

def DEFAULT_COMPILE_SDK_VERSION = 27
def DEFAULT_BUILD_TOOLS_VERSION = "27.0.3"
def DEFAULT_TARGET_SDK_VERSION = 26

AndroidManifest.xml

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE"/>

1 个答案:

答案 0 :(得分:0)

您应该在正确的AndroidManifest.xml中添加权限。 在android / app / src / main / AndroidManifest.xml而不是其他任何AndroidManifest.xml中添加所需的权限

尝试将其添加到以下路径android / app / src / AndroidManifest.xml

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE"/>