6

I have followed all of the most up-to-date guides and suggestions for getting react-native-google-mobile-ads to work with an Expo managed workflow, including these:

How to use react-native-google-mobile-ads with Expo?

How do I use react-native-google-mobile-ads with Expo and Expo Go?

But I keep getting the same error:

ERROR TypeError: null is not an object (evaluating 'RNAppModule.eventsNotifyReady')

It would seem that this error originates in this jest.setup.ts file: https://github.com/invertase/react-native-google-mobile-ads/blob/main/jest.setup.ts

but I have no idea what the error is or how to overcome it.

This error happens when I initiate interstitial.load() as per the official documentation.

Any help would be greatly appreciated.

Muzly
  • 83
  • 6

1 Answers1

1

Ran into this same problem. Turns out the command to use was hidden in their docs at the end of the build steps without any explanation.

https://docs.page/invertase/react-native-google-mobile-ads#setting-up-google-admob

Using react-native-google-mobile-ads, Expo Go will no longer be able to handle linking all the native dependencies. So you'll have to use EAS to build it. Per the docs, you can use npx eas-cli build --profile development to build for development. Alternatively, to install locally rather than on EAS servers, add the --local flag to that command. Just note that if building locally you may need to set the Android SDK path following the instructions to edit your eas.json at Expo build EAS - local - SDK location not found.

After building for Android (I don't have a Mac so I can't speak for development on iOS), it generates an apk which you need to install on your device. I'm sure there's a way to install this on an emulator too.

Once you've opened that app, it will direct you to start a development server using expo start --dev-client. This will run a dev server similar to the usual Expo Go. It pulls up a QR code which you can scan and it will take you into your app. Hot reload works as expected too. Doing this my test banner ad showed up without any errors.

The same solution is discussed here.

Kollin Murphy
  • 395
  • 1
  • 3
  • 7