React-native-admob: Once integrated the admob, application not loading

Created on 29 Jan 2020  路  14Comments  路  Source: sbugert/react-native-admob

I done all the steps to add react-native-admob and linking the application. but after that it is not getting loaded

All 14 comments

Same here

Did you make sure you added the meta-data tag in your AndroidManifest.xml within the application tag?
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-3940256099942544~6300978111"/>
Make sure you use the ~ instead of / for the AppID here.
And within your AdMobBanner tag in your actual codes, use the AppID with / instead of ~, like this:
<AdMobBanner adSize="banner" adUnitID="ca-app-pub-3940256099942544/6300978111" testDevices={[AdMobBanner.simulatorId]} />

Edit:
This may be obvious but I did made the mistake on my first try. On your production version, make sure you use your AdMob ApplicationID in the AndroidManifest and the AdUnitID in the Ad itself. Otherwise the real ad will not show.

Thanks for your answer.

I didn't had this meta-data. So I did but nothing change.
What can I show you to verify the configuration?

Just to be sure, her is what I've done:
I've replaced 'APPLICATION_ID' by mine.
I replaced the second parameter by the test one whic is ca-app-pub-3940256099942544/8691691433.

Is that good?

For the installation, I did as specified in the instruction:
npm i react-native-admob -S
react-native link

What version of RN does your app use? If 6.x you shouldn't need to do "react-native link" or any manual linking.
Also, I installed using @next
yarn add react-native-admob@next
or
npm i --save react-native-admob@next
Not sure how much of difference does that make though.

I'm using react native 0.59.9 ...

I see, then you probably need the linking. If you are on <6.0, when you install a new module it could be problem with AndroidX. Couple things I have tried dealing with AndroidX,

  1. Add the following lines to android/gradle.properties:
    android.useAndroidX=true
    android.enableJetifier=true
  1. run the following commands on the project folder:
    npm i jetifier
    npx jetify

If your project is rather simple and small, you might also consider creating a new project with the latest version of RN to replace your existing project. I found that the newer version has better integration with AndroidX library.

I tried your solution and I had hope that it would work but I get this error instead
Task :react-native-admob:compileReleaseJavaWithJavac FAILED
/APP_PATH/node_modules/react-native-admob/android/src/main/java/c
om/sbugert/rnadmob/RNAdMobRewardedVideoAdModule.java:20: error: RNAdMobRewardedVideoAdModule is not
abstract and does not override abstract method onRewardedVideoCompleted() in RewardedVideoAdListen
er
public class RNAdMobRewardedVideoAdModule extends ReactContextBaseJavaModule implements RewardedVideoAdListener {

I updated the lib with
npm install react-native-admob@next

then did npx jetifier

Now it builds, but ... it is impossible to open the app...

I also ran into lots errors before it finally runs. Initially as soon as the app installed and ran in the emulator it crashed right away. For me, adding the meta-data and setting the test appID correctly fixed the crash. I was testing with the small banner ads though. I added the meta-data tag inside the application tag and before the activity tag. I got it working on Android, though I have not done the iOS version yet. It took me a long time to get it to work too.

Ok, thanks anyway for your precious help.

It scrares me that I have to manage it on iOS after lol

I will reset all I've done and try harder

Good luck. Hope you get it to work soon.

Same here in ios
Using
"react-native-admob": "^2.0.0-beta.6",

Hey all, I'm seeing the same error, I cannot open the app after the changes, does anyone know how to solve it?

Was this page helpful?
0 / 5 - 0 ratings