RNFS.readDir() error Attempt to get length of null array
Reference to https://github.com/itinance/react-native-fs/issues/462
I followed the above issue solution, still got the same error:
the code:
const granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE, ); if (granted === PermissionsAndroid.RESULTS.GRANTED) { console.log('onPressDownloads write granted...'); try { let files = RNFS.readDir(RNFS.DownloadDirectoryPath); console.log("onPressDownloads files: ", files); } catch (error) { console.log("onPressDownloads error: ", error); } }
I am using React-native info: "react-native-fs": "^2.16.6",
info Fetching system and libraries information... System: OS: macOS Mojave 10.14.6 CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz Memory: 366.02 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 13.12.0 - /usr/local/bin/node npm: 6.14.4 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 Android SDK: API Levels: 23, 25, 26, 27, 28, 29 Build Tools: 27.0.2, 27.0.3, 28.0.2, 28.0.3, 29.0.3 System Images: android-22 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom IDEs: Android Studio: 3.1 AI-173.4907809 Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild npmPackages: react: ^16.9.0 => 16.9.0 react-native: ^0.61.5 => 0.61.5 npmGlobalPackages: create-react-native-app: 2.0.2 react-native-asset: 2.0.0 react-native-cli: 2.0.1 react-native-cn-richtext-editor: 1.0.42 react-native-git-upgrade: 0.2.7 react-native: 0.61.5
I have the use permissions in AndroidManifest.xml file:
and under <application tag, I have android:sharedUserId="android.uid.system"
I can read other folders like RNFS.DocumentDirectoryPath, but for folder RNFS.DownloadDirectoryPath, I got this error:
ExceptionsManager.js:126 Unhandled promise rejection Error: Attempt to get length of null array at fn (NativeModules.js:99) at readDirGeneric (FS.common.js:181) at Object.readDir (FS.common.js:253) at Object._callee5$ (index.js:453) at tryCatch (runtime.js:63) at Generator.invoke [as _invoke] (runtime.js:293) at Generator.next (runtime.js:118) at tryCatch (runtime.js:63) at invoke (runtime.js:154) at runtime.js:164
Please help!!
Thanks
I faced the same issue
Same error, is there any solution for that?
Same error, is there any solution for that?
Did you try this?
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
any updates on this ?
Occurred the same problem on Android when I tried to backup data files through ADB shell, although I chmod/chown these file's privilege, not fix...