Cannot share file on stand alone builds

  1. SDK Version: 37
  2. Platforms(Android/iOS/web/all): Android

I’m making a very simple app allowing users to share sound files. The sharing mechanism works as it should on dev versions (anything running from expo start) as well as on the published app when opened with Expo. But the app is available on the Play Store and this specific version cannot share files. It also happens with stand alone builds shared outside of the store (apk and aab). I cannot test with iOS as I cannot afford the developer fee right now.

I’ve isolated the issue as potentially coming from the Asset library. Asset.downloadAsync should result in a localUri reprensenting the local URL of the file, beginning with file://, however on stand alone builds the localUri begins with asset:// and that causes the Sharing.shareAsync to fail.

Here is the code where the error happens :

try {
  const asset = Asset.fromModule(sounds[sound.file]);
  await asset.downloadAsync();
  await Sharing.shareAsync(asset.localUri);
} catch (err) {
  Alert.alert(
    'Sharing failed.',
    err.message
  );
}

The resulting error message is “Only local file URLs are supported (expected scheme to be ‘file’, got ‘asset’)”.

Maybe I’m missing a step somwhere in the process, but I can’t find what.

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