AdMob banner ad not showing

I use admob in my application, it works fine, but suddenly it stopped showing ads at all. Bellow are my codes that 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 the adMob website, as I said that it works a few days ago.

Below you will find a few lines from the logarithm that may be related to my problem:

 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 repeat the warning several times, and more appears when I click on the empty area where the ad should be displayed

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

Filtered Log Code 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 searched everywhere for a solution, and also looked at some similar ones, but not one of them helped me.

+8
android admob ads
source share
7 answers

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

+5
source share

Use the lines below the 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 this

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

because this line will be used when your application is ready for publication on the Google Play Store.

You can put your device identifier instead of "AC98C820A50B4AD8A2106EDE96FB87D4 . " Code to get device ID:

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

Read 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

+11
source share

Check if you have the latest adMob and GooglePlayServices lib.

+2
source share

Place the banner in LinearLayout just like this, I encountered the same problem and I fixed it by placing it in a linear layout

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:id="@+id/linearLayout"> <com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adSize="BANNER" ads:adUnitId="ca-app-pub-8056472942589154/2652831823" android:layout_alignBottom="@+id/saida" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> </LinearLayout> 
+1
source share

In my case, the ad did not appear until I gave him enough space.

Before it was like

 <LinearLayout android:orientation="vertical" android:background="@color/primary" android:layout_width="match_parent" android:layout_height="90dip"> <ImageView android:onClick="goBack" android:clickable="true" android:src="@drawable/ic_arrow_back_white_48dp" android:layout_width="50dip" android:layout_height="50dip"/> <com.google.android.gms.ads.AdView android:layout_gravity="center_horizontal" android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adSize="BANNER" ads:adUnitId="@string/dwn_bnr_ad"/> 

Here, adview has a height of wrap_content, so it is configured to reach its height, but its parent (LinearLayout) has a strict height of 90dip, which does not allow adView to take up enough space to display ads.

So what I did, it just changed the height of LinearLayout to wrap_content, then everything got fine

+1
source share

Have you returned to your admob account to register your ad application and receive a new longer publisher number with the preface "ca-app-pub-" instead of the prefix "pub"?

Nowhere in the β€œbanner ads 1” instructions on the Google Admob developer site β€œGoogle Mobile Ads SDK” does it mention the need to return to the admob account to do this.

This stupid mistake held me back for several days.

0
source share

In my case, I had the code below in the buildscript section of the buildscript project build.gradle

Make sure maven {url "https://maven.google.com"} is under allProjects > repositories :

 allprojects { repositories { jcenter() maven { url "https://maven.google.com" } } } 
0
source share

All Articles