MediaLibrary.createAlbumAsync not working on compiled app (Android 5.1.1)

  1. SDK Version: 35.0.0
  2. Platform: Android

I am trying to save in a .txt file all what I have stored in a variable named “payload”. I am doing it with the following code:

import * as Permissions from ‘expo-permissions’
import * as ExpoFileSystem from ‘expo-file-system’
import * as MediaLibrary from ‘expo-media-library’;

state = this.state;
const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
if (status === “granted”) {
console.log(“Estatus = “, status);
let fileUri = ExpoFileSystem.documentDirectory + state.name+”.txt”;
await ExpoFileSystem.writeAsStringAsync(fileUri, JSON.stringify(payload), { encoding: ExpoFileSystem.EncodingType.UTF8 });
const asset = await MediaLibrary.createAssetAsync(fileUri);
await MediaLibrary.createAlbumAsync(“Outcrops”, asset, true);
}

This should create a directory named “Outcrops” and the files should be stored in it. The problem is that in a phone with Android 5.1.1 it is not working when I use the compiled app. In that phone, it only works when I emulate the app.

Instead, in another phone with Android 6, it works in both cases: emulating and with the compiled app.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.