2

In my React Native app, I'm trying to add the expo-mail-composer package using this guide.

I use react-native@0.64.0,
I added "install-expo-modules": "^0.2.8",
then "expo-mail-composer": "~11.3.0",

When I try to import the package with

import * as MailComposer from 'expo-mail-composer'

it throws the error

Cannot find native module 'ExpoMailComposer'
David Leuliette
  • 1,595
  • 18
  • 26
gkeenley
  • 6,088
  • 8
  • 54
  • 129
  • are you using expo-cli or react-native-cli? if you using expo cli then no need to add dependency or if you using react-native-cli then you should import its package to the respective platform android or ios – Bhavin Parghi Nov 08 '22 at 06:28

2 Answers2

2

This issue was resolved for me by creating a new development build:

eas build --profile development --platform android

Then downloading and installing that build on my device:

adb install --user 0 <path_to_apk>

I then ran the app with:

set APP_ENV=development&& npx expo start --dev-client

The app opened as normal after that, and MailComposer.composeAsync() appears to work.

(For reference, I'm developing on a physical Android device using the Managed workflow, and did not have to use npx install-expo-modules@latest.)

Rukt
  • 21
  • 4
  • 1
    Fixed my error for ExpoSharing. Seems odd that an Expo module requires a new Dev build, and that the Expo doc mentions nothing about needing a new Dev build. but oh well. Seems to fix my error too. – SeanMC Aug 08 '23 at 02:25
1

To use expo modules in a non-expo project (aka bare workflow), you need to install Expo modules first with:

npx install-expo-modules@latest

https://docs.expo.dev/bare/installing-expo-modules/

David Leuliette
  • 1,595
  • 18
  • 26