Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AdMob banner ad not showing

Tags:

android

ads

admob

I am using admob in my app, it was working fine but suddenly it stopped showing ads at all. Bellow is my codes i used:

mainActivity.xml:

<com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_ad_unit_id">
    </com.google.android.gms.ads.AdView>

MainActivity.java

        AdView mAdView = (AdView) findViewById(R.id.adView);

        AdRequest adRequest = new AdRequest.Builder().build();

        mAdView.loadAd(adRequest);

AndroidManifest:

 <uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="19" />

 <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<meta-data android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />  

<!--Include the AdActivity configChanges and theme. -->
<activity android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            android:theme="@android:style/Theme.Translucent" />

I followed all the instructions from adMob site as i said it was working few days ago.

Bellow are few line from logcat which may be related to my issue:

09-25 22:44:50.292: E/dalvikvm(18554): Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza

09-25 22:45:07.209: E/Ads(18554): JS: Uncaught ReferenceError: renderAd is not defined (https://googleads.g.doubleclick.net/mads/gma:1)
09-25 22:45:07.209: E/Web Console(18554): Uncaught ReferenceError: renderAd is not defined:1
09-25 22:45:07.209: E/Ads(18554): JS: Uncaught ReferenceError: onLoad is not defined (https://googleads.g.doubleclick.net/mads/gma:1)
09-25 22:45:07.209: E/Web Console(18554): Uncaught ReferenceError: onLoad is not defined:1

I get bellow warning repeatedly and it appears more when i click the blank area where ad should be showing

09-25 22:46:10.911: W/PicturePileLayerContent(18554): Warning: painting PicturePile without content!

This is filtered logcat with "ads"

09-25 23:39:25.948: I/Ads(28874): Starting ad request.
09-25 23:39:25.948: I/Ads(28874): Use AdRequest.Builder.addTestDevice("8FCD71CAAE776558876AAA9BA964245A") to get test ads on this device.

09-25 23:39:26.919: I/Ads(22050): App index is not enabled
09-25 23:39:30.432: E/Ads(28874): JS: Uncaught ReferenceError: renderAd is not defined (https://googleads.g.doubleclick.net/mads/gma:1)
09-25 23:39:30.442: E/Ads(28874): JS: Uncaught ReferenceError: onLoad is not defined (https://googleads.g.doubleclick.net/mads/gma:1)
09-25 23:39:30.442: I/Ads(28874): Scheduling ad refresh 60000 milliseconds from now.
09-25 23:39:30.472: I/Ads(28874): Ad finished loading.

I have searched everywhere for the solution and also looked at some similar but non of them helped me.

like image 686
Darshan Avatar asked Sep 25 '15 17:09

Darshan


People also ask

Why are my banner ads not showing up?

Ads won't show if you haven't integrated the Google Mobile Ads SDK correctly. Is your ad implementation code working properly? Test your implementation code to check that ads can show. You can also use ad inspector to test your app's ad serving.

Why is my Google AdMob app not showing ads?

Make sure you have updated AdMob with your payment details. Make sure that the ads you created in AdMob are banner ads. Check your AdMob dashboard to see the status of your ads, are they active? Verify you used the correct Ad Unit Id.

How long does it take for AdMob ads to show?

When apps are newly registered with AdMob, it typically takes up to an hour and a few ad requests to allow inventory to build. Because of this, you may not see live impressions immediately. Note: In some cases, it may take longer than an hour. Please wait 24 hours before seeking additional help.

How do I know if AdMob ad is working?

Test devices You can configure your device as a test device and use your own ad unit IDs that you've created in your AdMob account. When you enable a test device, the AdMob Network sends production ads in test mode to your device using the ad unit IDs you've created in your AdMob account.


2 Answers

Use below lines of code

AdView mAdView = (AdView) findViewById(R.id.adView);

AdRequest request = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)        // All emulators
.addTestDevice("AC98C820A50B4AD8A2106EDE96FB87D4")  // My Galaxy Nexus test phone
.build();


mAdView.loadAd(request );

instead of using this

AdRequest adRequest = new AdRequest.Builder().build();

because this line will be used when your application would be ready for publish on Google Play Store.

You can place your device's id in place of "AC98C820A50B4AD8A2106EDE96FB87D4". Code to get device id:

String android_id = Settings.Secure.getString(getContext().getContentResolver(),
            Settings.Secure.ANDROID_ID);

Please read these carefully:

https://developers.google.com/admob/android/targeting#test_ads

https://developers.google.com/admob/android/quick-start

See this

enter image description here

enter image description here

like image 92
Ashish Tiwari Avatar answered Sep 27 '22 01:09

Ashish Tiwari


This problem is solved by uninstalling the app manually and reinstalling again without making any changes!!

like image 21
Darshan Avatar answered Sep 27 '22 01:09

Darshan