Reputation: 6257
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"]}
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?
Upvotes: 6
Views: 2987
Reputation: 6257
I've found the solution. Here are the steps to take:
yarn add react-native-google-mobile-ads
app.json
(out of the expo object)eas login
in your terminal and enter your credentialseas whoami
expo-dev-client
eas device:create
. Else, move on to the next line.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..apk
for android) directly on your simulator. This will install it on it.expo start --dev-client
Upvotes: 6