Open mattveraldi opened 5 years ago
Hi there,
Exact same problem here. React Native Environment Info: System: OS: Windows 10 CPU: x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz Memory: 2.91 GB / 15.86 GB Binaries: Yarn: 1.5.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.2.0 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 3.2.0.0 AI-181.5540.7.32.5056338
Package.json infos : "react": "^16.5.0", "react-native": "^0.57.1", "react-native-admob": "^2.0.0-beta.5",
It compiles but crashes on emulator when it tries to launch the app :(
I tried that solution and it works great : https://github.com/sbugert/react-native-admob/issues/370
I tried that solution and it works great :
370
Thank you, unfortunately It didn't work for me, it still crashes
I finally found a solution that works for me:
I figured out that in the build.gradle file placed in react-native-admob/android/ targetSdkVersion
was 22, but in my app's build.gradle
is 26 so I changed the admob so that they match.
targetSdkVersion 26
Also, i hardcoded the dependencies of admob's build.gradle so that play-service-ads is always set to the 16.0.0 version.
compile 'com.google.android.gms:play-services-ads:16.0.0'
this worked for me, at least on the emulator. @grean let me know if it works for you aswell.
EDIT: doesn't work on real devices
Here my context : compileSdkVersion 27 buildToolsVersion "27.0.3" minSdkVersion 21 targetSdkVersion 27 I'm not expert in gradle configuration and i use lots of dependencies in my project. So i just can tell you that it works for me since i've added the good line in AndroidManifest.xml I have to change the version of a line too : implementation 'com.google.android.gms:play-services-auth:16.0.1' from version 15.0.0 to 16.0.1
hi guys its way its answer
1-npm i --save react-native-admob
2-react-native link react-native-admob
then==>>
3- in manifest <meta-data android:name="com.google.android.gms.ads.YOURpackegName" android:value="ca-app-pub-***********"/>
4- add implementation 'com.google.android.gms:play-services-ads:12.0.0'
in gradel
5-in build gradel react-native-admob:
compileSdkVersion 26 buildToolsVersion "28.0.3"
6- then you get this error
go to node-modules/react-native-admob/RNAdmobBanner.js & node-modules/react-native-admob/ PublisherBanner and Replace line 48 to 86
FIRST ==> import PropTypes from "prop-types";
=>OLD:
adViewDidReceiveAd: React.PropTypes.func, didFailToReceiveAdWithError: React.PropTypes.func, adViewWillPresentScreen: React.PropTypes.func, adViewWillDismissScreen: React.PropTypes.func, adViewDidDismissScreen: React.PropTypes.func, adViewWillLeaveApplication: React.PropTypes.func, admobDispatchAppEvent: React.PropTypes.func, ...View.propTypes,
=>NEW:
bannerSize: PropTypes.string, adUnitID: PropTypes.string, testDeviceID: PropTypes.string, adViewDidReceiveAd: PropTypes.func, didFailToReceiveAdWithError: PropTypes.func, adViewWillPresentScreen: PropTypes.func, adViewWillDismissScreen: PropTypes.func, adViewDidDismissScreen: PropTypes.func, adViewWillLeaveApplication: PropTypes.func, admobDispatchAppEvent: PropTypes.func,
@AMINDRH91 thank you so much it worked for me
I tried that solution and it works great :
370
Hi I tried this solution but it did not work until I changed the admob id from this ca-app-pub-3940256099942544/6300978111
to this ca-app-pub-3940256099942544~6300978111
in AndroidManifest.xml
Pay attention to tilt. I do know not if it is right or not but changing slash to title worked for me.
Complete code
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-3940256099942544~6300978111"/>
@AMINDRH91 thank you i worked for me
Unfortunately none of this worked for me... But I finally solved my problem so here I post all the steps I followed to make it work:
1- I removed react-native-admob with npm uninstall react-native-admob
and I manually unlinked it from the android project;
2- With cd android && gradlew clean && cd .. && react-native run-android
I cleaned and runned the app to see if everything was ok.
3- With npm install --save react-native-admob@next
I installed the latest release, then I linked it with react-native link
, but it still did crash on start but I solved the issue hardcoding google play services' version on react-native-admob's build.gradle file that way: compile 'com.google.android.gms:play-services-ads:16.0.0'
.
4- On real devices the banner wasn't showing up. What I found out is that if you have your Admob linked to your app with Google Play, banners only show up with consistency on the release version of the app.
Now everything works as it should.
Thank you for your help
Damn it's the 5th time i uninstall / install this module. I forgot to hardcode the play services module . Thanks for the fix i was going insane.
Maybe we will need to wait for the react-native-firebase to release the standalone module of admob in v6.0.0 but it can be months until that...
@mattveraldi compile 'com.google.android.gms:play-services-ads:16.0.0'
fixed it for me, thanks so much
@mattveraldi thank you so much for saving my life haha! I've tried plenty of solutions but nothing worked for me. Your solution worked perfectly!
Unfortunately none of this worked for me... But I finally solved my problem so here I post all the steps I followed to make it work: 1- I removed react-native-admob with
npm uninstall react-native-admob
and I manually unlinked it from the android project; 2- Withcd android && gradlew clean && cd .. && react-native run-android
I cleaned and runned the app to see if everything was ok. 3- Withnpm install --save react-native-admob@next
I installed the latest release, then I linked it withreact-native link
, but it still did crash on start but I solved the issue hardcoding google play services' version on react-native-admob's build.gradle file that way:compile 'com.google.android.gms:play-services-ads:16.0.0'
. 4- On real devices the banner wasn't showing up. What I found out is that if you have your Admob linked to your app with Google Play, banners only show up with consistency on the release version of the app. Now everything works as it should.Thank you for your help
this is not working for me, actually i've did all but nothing works
You could use your own fork or use my fork to avoid hardcoding things
"react-native-admob": "git+ssh://git@github.com:smakosh/react-native-admob.git",
Try use androidx
Inside node_modules/react-native-admob =>
In build.gradle
edit like this ->
implementation "androidx.annotation:annotation:1.1.0" . <-- add
implementation 'com.google.android.gms:play-services-ads:16.0.0' <-- add
//implementation 'com.google.android.gms:play-services-ads:+' . <-- remove
replace import android.support.annotation.Nullable
with import androidx.annotation.Nullable;
inside,
RNAdMobBannerViewManager.java,
RNAdMobInterstitialAdModule.java,
RNAdMobRewardedVideoAdModule.java,
RNPublisherBannerViewManager.java
Will remove the errors and crash.
implementation "androidx.annotation:annotation:1.1.0" . <-- add implementation 'com.google.android.gms:play-services-ads:16.0.0'
This worked for me.
IN ...\android\app\src\main\AndroidManifest.xml
CHANGE
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544/**********"/>
TO
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~**********"/>
Change: / to ~
@aswincheriyala thank you.
Hi, I have a RN 0.50.3 project running:
And I need to set up some admob banners. I installed and linked successfully react-native-admob but my app crashes on startup without giving me any error. it's very strange and I still can't figure out why it happens.
It used to work with an old version of react-native-admob, but I lost the package.json file and I can't remember which version it was.