react-native-google-mobile-ads icon indicating copy to clipboard operation
react-native-google-mobile-ads copied to clipboard

[🐛] Google Banner Ads not showing

Open wetzelschultz opened this issue 1 year ago • 5 comments

I want the banner ads to show up but there is some issue for me. The banner ads in my emulator is "Test Ads", I not sure how to make it become a real ads instead of test ads. I not sure which part of the coding I had done wrong. Then when I try the app in my real phone, the ads is not showing at all, not even the "Test Ads". What should I do?

Screenshot of my emulator showing "Test Ads Screenshot_1657033873

Screenshot of my phone showing no ads WhatsApp Image 2022-07-05 at 11 19 33 PM

My code (I am showing a dummy adUnitID number here due to privacy concern)

import * as React from 'react';
import {
  View,
  Text,
  Image,
  StyleSheet,
  ScrollView,
  TouchableOpacity,
  SafeAreaView,
} from 'react-native';

import { BannerAd, BannerAdSize } from 'react-native-google-mobile-ads';

const Home = ({ navigation }) => {

  const adUnitId = 'ca-app-pub-xxxxxxxx~xxxxxxxx';

  return (
    <SafeAreaView style={styles.container}>
      <ScrollView>

        <Text>{'\n'}</Text>

        {/* Advertisement banner */}
        <View style={{ alignItems: 'center' }}>

          <BannerAd
            unitId={adUnitId}
            size={BannerAdSize.FULL_BANNER}
            requestOptions={{
              requestNonPersonalizedAdsOnly: false,
            }}
          />

        </View>

      </ScrollView>
    </SafeAreaView >
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#f0f0f0',
    padding: 8,
  },
  startButton: {
    height: 120,
    width: 180,
    margin: 5,
    padding: 10,
    backgroundColor: 'white',
    justifyContent: 'center',
    alignItems: 'center',
  },
  startButtonII: {
    height: 230,
    width: 180,
    margin: 5,
    padding: 10,
    backgroundColor: '#1976D2',
    justifyContent: 'center',
    alignItems: 'center',
  },
  buttonText: {
    //color: 'white',
    fontSize: 16,
    padding: 10,

  },
  buttonText2: {
    color: 'white',
    fontSize: 18,
    padding: 10,

  },
  textTitle: {
    padding: 10,
    //fontSize: 28,
    fontSize: 22,
  },
  textTitle2: {
    fontSize: 22,
  },
  imageStyle: {
    height: 180,
    width: 180,
    alignItems: 'center',
  },
});

export default Home;

wetzelschultz avatar Jul 05 '22 15:07 wetzelschultz

The banner ads in my emulator is "Test Ads", I not sure how to make it become a real ads instead of test ads.

That's expected. Emulators are automatically marked as test devices and only show test ads.

I not sure which part of the coding I had done wrong.

Assuming you followed the installation instructions correctly, your code looks fine.

What should I do?

Take a look at the documentation about common reason for ads not showing.

Good luck

DoctorJohn avatar Jul 10 '22 13:07 DoctorJohn

Experiencing the same issue too. Ads are showing on an emulator but not on a real device

dhatGuy avatar Aug 09 '22 07:08 dhatGuy

@QuyetAQ that is a non-collaborative attitude and is in general demotivating for others that are contributing time. Please understand it's an open source project. That means you are the developer, not the user. It's a free puppy, not free beer. Please reflect on that. https://hackernoon.com/i-thought-i-understood-open-source-i-was-wrong-cf54999c097b

mikehardy avatar Aug 20 '22 22:08 mikehardy

@QuyetAQ that is a non-collaborative attitude and is in general demotivating for others that are contributing time. Please understand it's an open source project. That means you are the developer, not the user. It's a free puppy, not free beer. Please reflect on that. https://hackernoon.com/i-thought-i-understood-open-source-i-was-wrong-cf54999c097b

Very sorry team, I didn't mean to complain. Everything you give to the community is very helpful. But when installing version 7.0.1, after building the app:

  • Banner advertising displays "Test ad" on the simulator.
  • Banner ads do not display on real devices. Although I have read the document carefully and consulted on the community, I have not found a way to fix it :(

QuyetAQ avatar Aug 22 '22 14:08 QuyetAQ

You will have to provide a lot more information about why it is not showing (possibly adding debugging statements in node_modules if existing logging statements are not sufficient) to determine why you are not seeing ads. It is probably one of the common no-fill cases explained in the link posted in the comments above yours. There should be messages in the logs indicating what's going on though

mikehardy avatar Aug 22 '22 15:08 mikehardy

@mikehardy , after checking the information on Google AdMob help website, I find that I did not have the following code in app/build.gradle:

dependencies { implementation 'com.google.android.gms:play-services-ads:21.2.0' }

Do you think this might be the reason why real ads are not showing on real mobile device?🤔

wetzelschultz avatar Oct 07 '22 11:10 wetzelschultz

@wetzelschultz no, through the magic of auto-linking we specify that dependency here in our module's build.gradle and your app auto-magically gets it:

https://github.com/invertase/react-native-google-mobile-ads/blob/365f1a4b733a3efa7a81fd174fcc2839cbbfd23e/android/build.gradle#L120

If you are not seeing ads, there is some other problem. There are a great many reasons ads won't fill, here's a link to a guide discussing the same https://docs.page/invertase/react-native-google-mobile-ads/common-reasons-for-ads-not-showing

mikehardy avatar Oct 07 '22 15:10 mikehardy

@mikehardy The app/build.gradle in my project did not have this code either:

https://github.com/invertase/react-native-google-mobile-ads/blob/365f1a4b733a3efa7a81fd174fcc2839cbbfd23e/android/build.gradle#L120

Since you had mentioned that there is auto-linking, does it mean that I no need to take any action for my app/build.gradle to have the code above? Am I right?🤔

wetzelschultz avatar Oct 07 '22 16:10 wetzelschultz

@wetzelschultz with apologies, these are basic react-native questions and are not specific to this repo at all. I have provided a link to the documentation and I need you to follow that, read it, and learn using that resource

mikehardy avatar Oct 07 '22 16:10 mikehardy

I am also facing the same issue please help me. I am using this version "react-native-google-mobile-ads": "^8.2.0" image

swatantragoswami09 avatar Oct 30 '22 16:10 swatantragoswami09

@swatantragoswami09 you are posting comments around on various issues that are nearly content free, I am starting to consider them disruptive spam. Please read https://stackoverflow.com/help/how-to-ask and please read all our install documentation, and please examine our example app in your environment.

Do not post again until you have done so.

mikehardy avatar Oct 30 '22 16:10 mikehardy

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Dec 05 '22 20:12 github-actions[bot]