birdofpreyru / react-native-fs

File system access for React Native
https://dr.pogodin.studio/docs/react-native-file-system
Other
153 stars 11 forks source link

Cannot read property 'DocumentDirectoryPath' of undefined #71

Open losh11 opened 4 days ago

losh11 commented 4 days ago

I'm unable to get my app running on android, which errors with Cannot read property 'DocumentDirectoryPath' of undefined. Currently using the latest build of rnfs: "@dr.pogodin/react-native-fs": "^2.28.0".

And here's what the code looks like where it errors:

import RNFS from '@dr.pogodin/react-native-fs';

const pogDir = RNFS.DocumentDirectoryPath;

Works as expected on iOS devices, but doesn't work on Android.

Full error message:

 (NOBRIDGE) ERROR  Warning: TypeError: Cannot read property 'DocumentDirectoryPath' of undefined 
    at Suspense
    at Freeze (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:356111:23)
    at DelayedFreeze (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:356065:22)
    at InnerScreen (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:355912:41)
    at Screen (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:356037:50)
    at MaybeScreen (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:355407:24)
    at RNSScreenContainer
    at ScreenContainer (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:356333:31)
    at MaybeScreenContainer (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:355397:23)
    at RCTView
    at View (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:64713:43)
    at Background (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:344645:21)
    at CardStack (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:353325:36)
    at RNCSafeAreaProvider
    at SafeAreaProvider (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:352156:24)
    at SafeAreaProviderCompat (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:353048:24)
    at RNGestureHandlerRootView
    at GestureHandlerRootView (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:336593:21)
    at StackView (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:343699:36)
    at PreventRemoveProvider (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:348772:25)
    at NavigationContent (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:349559:22)
    at anonymous (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:349575:27)
    at StackNavigator (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:343576:18)
    at EnsureSingleNavigator (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:345680:24)
    at BaseNavigationContainer (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:345276:28)
    at ThemeProvider (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:351088:21)
    at NavigationContainerInner (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:350976:26)
    at RootNavigator
    at RNGestureHandlerRootView
    at GestureHandlerRootView (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:336593:21)
    at PersistGate (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:463697:22)
    at Provider (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:134102:21)
    at App
    at RCTView
    at View (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:64713:43)
    at RCTView
    at View (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:64713:43)
    at AppContainer (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:64586:25)
    at plasma(RootComponent) (http://192.168.1.60:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.plasma&modulesOnly=false&runModule=true:117226:28)

App is using latest build of react native. Running on a Samsung S24 Ultra (latest android version).

$ java --version
java 17.0.12 2024-07-16 LTS
Java(TM) SE Runtime Environment (build 17.0.12+8-LTS-286)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.12+8-LTS-286, mixed mode, sharing)
birdofpreyru commented 4 days ago

This error looks like entire module failed to properly load & link to the TS side; it well may be an error in your app setup, rather than a problem with the library per se. Do you use old or new RN architecture? Does the example app work for you? You don't try to use it alongside the original RNFS library?