5

I have an Expo app that works well. Now, I would like to add a few ads before publishing it on Play Store in order to make a few bucks. Expo says their in-house ads package is deprecated and that I must use react-native-google-mobile-ads.

Because react-native-google-mobile-ads is a native package, it means I need to perform special tasks, and it's a bit unclear on how to proceed from here.

From what I've understood, I need to:

  • install expo-dev-client and react-native-google-mobile-ads

  • add react-native-google-mobile-ads in the app.json 's expo plugin

"expo": { "plugins": ["react-native-google-mobile-ads"]}
  • add my adMob api key in app.json

"react-native-google-mobile-ads": {
"android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
"ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx"
  }
  • create an account on https://expo.dev and run eas login in my terminal

  • then run eas build --profile development --platform android to generate a build

  • since expo-go won't work anymore because of the native package, I won't be able to run the app on a real phone. I will have to finish the development on an android simulator by running expo start --dev-client and press a to open the app on the android emulator.

  • then add the code to display the ads.

  • Once it's done, run eas build --platform android to create a build

  • follow the long process to upload my first build to the Play Console

  • Publish it as a beta app, send the link to adMob review.

  • Once adMob says all's good, I can publish the app for good on the PlayStore.

It's not a smooth process... I don't know why Expo decided to remove such a common package! Can someone confirm to me this is the right process? Or maybe there is a simpler approach, with a different library?

DoneDeal0
  • 5,273
  • 13
  • 55
  • 114

1 Answers1

4

I've found the solution. Here are the steps to take:

  • yarn add react-native-google-mobile-ads
  • add your adMob credential in app.json (out of the expo object)
  • suscribe to Expo's EAS.
  • run eas login in your terminal and enter your credentials
  • make sure you're correctly logged-in by running eas whoami
  • make sure you have Android studio and SDK 31 installed
  • make sure you have Java 11 Zulu installed
  • run expo install expo-dev-client
  • if you want to build for ios, run eas device:create. Else, move on to the next line.
  • run eas build --platform android --profile development --local (you may replace android by ios or just run the command without the --platform flag. I added --local because the cloud build wasn't working for unknown reasons). This will create a build on your machine.
  • drag and drop the build (.apk for android) directly on your simulator. This will install it on it.
  • run expo start --dev-client
  • your app is now running on your phone. Congratulations. The fast refresh is enabled and you may have some fun.
  • once you're happy with the coding, start the build again.
DoneDeal0
  • 5,273
  • 13
  • 55
  • 114
  • Hi, my local eas build is always failing with "/home/expo/workingdir/build/android/app/src/debug/AndroidManifest.xml:29:85-105 Error: [stderr] Attribute meta-data#com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT@value value=(true) from AndroidManifest.xml:29:85-105 [stderr] is also present at [:react-native-google-mobile-ads] AndroidManifest.xml:19:13-34 value=(false)." Any idea why this happens? :/ – AnyamBorogass Oct 12 '22 at 08:13
  • Sadly, no. These build tools are constantly changing and introducing breaking changes. It's just tiring in the long run lol. – DoneDeal0 Oct 12 '22 at 09:07
  • Thank you, but this is not a solution, this is a workaround. – Serdar D. Feb 03 '23 at 01:08
  • I am getting this error-- Android builds are supported only on Linux and macOS `eas build --platform android --profile development --local` – ManirajSS Feb 12 '23 at 08:28
  • I've only tested this method on osx. – DoneDeal0 Feb 12 '23 at 10:31