Why you'll remove AdMob's native integration with Expo

I’m having several problems integrating Google AdMob ads since they will remove the documentation from the official Expo site. I come here asking you to please return with era before

You need to migrate your code base to GitHub - invertase/react-native-google-mobile-ads: React Native Google Mobile Ads enables you to monetize your app with AdMob. package

It is this kind of error that appears to me when I follow the installation instruction.

Invariant Violation: TurboModuleRegistry.getEnforcing(…): ‘RNGoogleMobileAdsModule’ could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes

Invariant Violation: “main” has not been registered. This can happen if:

  • Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
  • A module failed to load due to an error and AppRegistry.registerComponent wasn’t called., js engine: hermes
    at node_modules\react-native\Libraries\Core\ExceptionsManager.js:null in reportException
    at node_modules\react-native\Libraries\Core\ExceptionsManager.js:null in handleException
  • … 7 more stack frames from framework internals

The same error occured to me . turns out you cant run ur app locally in expo go anymore Now you must create a native standalone build and test it accordingly . run npx expo prebuild to create the ios and android directories and then npx run:android to run the project on ur physical device connected through USB .Also you must have android studio installed and configured under the Hood … Yikes

Yes, you’re right about that, but the rest is not completely correct :slight_smile:

You cannot use Expo Go with AdMob, because the native code for AdMob is no longer a part of Expo Go. So you should create a development build (unless you check in the code if you are running Expo Go and avoid calling AdMob in that case):

e.g.:

eas build -p android --profile development

A development build is basically a custom version of Expo Go that has all of your dependencies included (and only your dependencies.)

You do not need to run npx expo prebuild and you do not need Android Studio or Xcode installed. In fact, I would recommend against running npx expo prebuild (or npx expo run:android or npx expo run:ios which run prebuild automatically).

Prebuild basically switches you to the Bare workflow. If you want to switch back to the managed workflow you should delete the android and ios directories.

If you create a Development Build on eas then How would You test ur app in dev mode , should i have to create a new apk again and again , because by running prebuild my push notifications stopeed working

This works the same as Expo Go. You run npx expo start and open the dev build on your emulator or phone.

You only need to build again if you install a new dependency.

If you were using Expo Go before then you might not have the push notifications set up properly. Expo Go of course has its own android.package value, which is different from your app. I have not looked at notifications in a long time, so maybe read through the troubleshooting documentation and make sure you have everything set up correctly.

If you have run npx expo prebuild or npx expo run:android then you basically have a Bare workflow app. In a Bare app you need to do some extra stuff, I believe, so I suggest you delete the android directory, read through the troubleshooting docs and create a new development build with eas build --profile development and hopefully that will get it working correctly.

EDIT: This part of the troubleshooting guide might be relevant:

Thanks For the help :+1:

1 Like