sbugert / react-native-admob

A react-native component for Google AdMob banners
BSD 2-Clause "Simplified" License
1.13k stars 532 forks source link

Once integrated the admob, application not loading #502

Open iyyoo93 opened 4 years ago

iyyoo93 commented 4 years ago

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

Akeuuh commented 4 years ago

Same here

mochi08 commented 4 years ago

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.

Akeuuh commented 4 years ago

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?

Akeuuh commented 4 years ago

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

mochi08 commented 4 years ago

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.

Akeuuh commented 4 years ago

I'm using react native 0.59.9 ...

mochi08 commented 4 years ago

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

  2. 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.

Akeuuh commented 4 years ago

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 {

Akeuuh commented 4 years ago

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...

mochi08 commented 4 years ago

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.

Akeuuh commented 4 years ago

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

mochi08 commented 4 years ago

Good luck. Hope you get it to work soon.

bhagone commented 4 years ago

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

Rogielssilva commented 3 years ago

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

GustavoSantos16 commented 1 year ago

Same here, after changes all the configuration to stop the build error, app does not open :/