React-native-admob: Android: "The ad size and ad unit ID must be set before loadAd is called"

Created on 20 Sep 2017  路  12Comments  路  Source: sbugert/react-native-admob

I get this error on Android when I use
<AdMobBanner bannerSize="smartBannerPortrait" adUnitID={admob.banner} adViewDidReceiveAd={null} testDeviceID={__DEV__ ? 'EMULATOR' : ''} didFailToReceiveAdWithError={bannerError} />

need more info

Most helpful comment

Oh btw, the 2.0 has an adSize property instead of bannerSize

All 12 comments

I can imagine that the component is rendered before admob.banner has a value?

Maybe try:

```jsx
{ admob.banner &&

}

has the same problem.I use 2.0.0 beta

@kidmysoul please show an example of how you're using this banner. If you check out the example project in the repo you'll see it works just fine there, so it should be something related to how the library is used.

Oh btw, the 2.0 has an adSize property instead of bannerSize

@koenpunt

can't get it work. My code is simple like:

import { AdMobBanner } from 'react-native-admob'

  render() {
    return (
      <View style={styles.container}>
        <MyNavigator />
        {Platform.OS === 'android' &&
        <AdMobBanner
            adUnitID="ca-app-pub-1213123123123123123"/> }
      </View>
    );
  }

and I use 2.0.0 beta
"react-native-admob": "^2.0.0-beta.2",

@koenpunt

I finally got it work by add "adSize="banner"

but in the 1.* version, if no adSize property provided, the ad will automatically adjust it's width to the device width. How to do it in version 2? the "adSize="banner"" forces the width to 50 which looked not very well.
2017-10-13 15 42 11

@kidmysoul please open a new issue if you have problems with positioning, because that's no longer related to this issue.

@gsdias that you close this is because your problem is now solved?

The error is no longer there. At least using test id.

Good :)

@koenpunt

I finally got it work by add "adSize="banner"

it solved my problem. But not centered or it does not use device width.

but in the 1.* version, if no adSize property provided, the ad will automatically adjust it's width to the device width. How to do it in version 2? the "adSize="banner"" forces the width to 50 which looked not very well.
2017-10-13 15 42 11

if you use adSize instead of bannerSize it will be solved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

talaikis picture talaikis  路  3Comments

jonigl picture jonigl  路  4Comments

xencodes picture xencodes  路  5Comments

thekiwi picture thekiwi  路  4Comments

vu-dang picture vu-dang  路  5Comments