Expo CameraJa Photo Caching on Android


I have been trying to implement the provided cameraJa provided in the Expo Docs into my Expo based react-native app. When ever I open the Camera on my app, using my Android device, I get this error:

[Error: Directory ‘file:///data/user/0/host.exp.exponent/files/ExperienceData/%2540anonymous%252Fnew-app-4cd0edb5-6a9f-4172-b7a4-9d7df74efccb/photos’ could not be created.] Directory exists

And as a result no pictures taken are saved in the gallery when I enter it. I have tried relentlessly to figure out what to do here, I found one post about this that suggested I change:

“I think adding the options object with intermediates set to true should resolve. See below :)”

async componentDidMount() {
    try {
      await FileSystem.makeDirectoryAsync(
          intermediates: true,
    } catch (e) {

After this I get Error:

Directory ‘file:///data/user/0/host.exp.exponent/files/ExperienceData/%2540anonymous%252Fnew-app-4cd0edb5-6a9f-4172-b7a4-9d7df74efccb/photos’ could not be created.

  • node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:78:57 in
  • node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:398:4 in __invokeCallback

I really don’t know whats going on here. It seems like the app is supposed to be deleting the cache on the phone, but its not? Is this CamerJa intended to be used? or should I just be writing my own camera view from scratch?

There’s also another recurring error that I haven’t begun to investigate, because I have been stuck trying to get the former part figured out. I don’t think the two are related, it is below:

8:29:28 PM: [Unhandled promise rejection: TypeError: undefined is not a function (evaluating ‘_this.camera.getAvailablePictureSizesAsync(_this.state.ratio)’)]

  • src/views/CameraScreen.js:152:75 in _callee3$
  • node_modules/regenerator-runtime/runtime.js:62:44 in tryCatch
  • node_modules/regenerator-runtime/runtime.js:296:30 in invoke
  • node_modules/regenerator-runtime/runtime.js:114:28 in
  • node_modules/regenerator-runtime/runtime.js:62:44 in tryCatch
  • node_modules/regenerator-runtime/runtime.js:152:28 in invoke

Please help :joy:


There could be a permissions issue on Android. IIRC you sometimes need to grant apps access to to external storage on Android in order to write to the file system – that might be related to the problem at hand here.


I added CAMERA_ROLL permissions, which I verified gives permission to the EXPO app to STORAGE. No luck, same problem.


I just updated to SDK 28 and now it will save the photos to the gallery, and I can save them to the phone. However, I still get the error:

[Error: Directory ‘file:///data/user/0/host.exp.exponent/files/ExperienceData/%2540anonymous%252Fnew-app-4cd0edb5-6a9f-4172-b7a4-9d7df74efccb/photos’ could not be created.] Directory exists

And the photos in the gallery are not deleted when restarting the APP. How do I delete the directory, or at least delete the pictures between instance of using the camera or the app?


you could write code using the FileSystem module to delete stuff.


Hey Thanks!

I’m still new to RN and still trying to figure out exactly how the life cycle works. I fixed my issue by adding the two lines at the bottom of componentWillMount()

async componentWillMount() {
const { status } = await Permissions.askAsync(Permissions.CAMERA);
const { rollStatus } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
this.setState({ permissionsGranted: status === ‘granted’ });
this.setState({ rollPermissionsGranted: status === ‘granted’ });
FileSystem.deleteAsync(FileSystem.documentDirectory + ‘photos’);
FileSystem.makeDirectoryAsync(FileSystem.documentDirectory + ‘photos’);

And then deleted the contents of componentDidMount()

componentDidMount() {
//FileSystem.makeDirectoryAsync(FileSystem.documentDirectory + ‘photos’).catch(e => {
// console.log(e, ‘Directory exists’);

I can officially use the Camera with no errors, photos save to cache and clear upon re-activation of the camera. Although this feels a bit hackey.


Another weird thing going on with this CamerJa is the default zoom on my phone is set too high. Even though its default value is set to 0, the camera is zoomed in. Is the zoom supposed to work by default; as far as I can tell there are no buttons implemented to change the zoom value in app.