MediaLibrary - Working on Expo Go but not when built as a standalone application

I have an app that is fully tested and works as expected when running the app using expo start and opening Expo Go on an android device.

Since I have run expo build:android -t apk, downloaded the .apk and installed it on the same android device. The MediaLibrary no longer functions.

The concerned code is below:

      const {status} = await MediaLibrary.requestPermissionsAsync()
      if (status === 'granted') {
        const asset = await MediaLibrary.createAssetAsync(capturedImage.uri);
        // console.log("Loggin image asset after being saved to storage", asset)
        MediaLibrary.createAlbumAsync('ALBUM_NAME_HERE', asset)
        .then(() => {
          // console.log('Album created!');
        })
        .catch(error => {
          console.log('err', error);
        });
      }

asset never gets created, nothing showing in DCIM or similar.
ALBUM_NAME_HERE never gets created, assumingly because no asset is ever created.

It’s good to note that there is a little bit of capture manipulation in terms of
getSupportedRatiosAsync & getAvailablePictureSizesAsync. But I simply select the lowest ratio and then the lowest picture size, based on the lowest ratio.

This issue has been resolved.

The issue lies with the Classic build process, outputting an .apk file for android devices using this method, at least in my use-case; stops the MediaLibrary (and possibly other modules) from functioning.

The solution was to use EAS instead of Classic to output an “Android internal distribution build”.

The process for this was to install EAS
(see Building APKs for Android emulators and devices - Expo Documentation)

  1. Install EAS CLI npm i -g eas-cli
  2. In my case, eas.json didn’t exist in the project so I ran eas config to create it
  3. The following eas.json worked for me
{
  "cli": {
    "version": ">= 0.52.0"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal"
    },
    "preview": {
      "distribution": "internal",
      "android": {
        "buildType": "apk"
      }
    },
    "production": {}
  },
  "submit": {
    "production": {}
  }
}
  1. Run eas build -p android --profile preview