dira
dira

Reputation: 30594

AdMob does not refresh the Ads

Here is my AdView

<com.google.ads.AdView
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ads:adUnitId=""
    ads:adSize="BANNER"
    ads:testDevices="TEST_EMULATOR"
    ads:loadAdOnCreate="true"
/>

On Admob website, I have set 'Automatic Refresh' to 'Refresh Rate: 22 sec'.

Here is LogCat output:

12-10 11:59:20.757: I/Ads(30363): adRequestUrlHtml: <html><head><script .......

12-10 11:59:22.296: I/Ads(30363): Received ad url: <"url":  ..... 

12-10 11:59:47.085: I/Ads(30363): Refreshing ad.

12-10 11:59:47.390: I/Ads(30363): adRequestUrlHtml: <html><head><script ...........

12-10 11:59:48.339: I/Ads(30363): Received ad url: <"url": ..... 

12-10 11:59:49.394: I/Ads(30363): onReceiveAd()

12-10 12:00:09.276: I/Ads(30363): Refreshing ad.

12-10 12:00:09.558: I/Ads(30363): adRequestUrlHtml: <html><head><script ...... 

12-10 12:00:10.046: I/Ads(30363): Received ad url: <"url":  ...... 

12-10 12:00:11.448: I/Ads(30363): onReceiveAd()
12-10 12:00:31.463: I/Ads(30363): Refreshing ad.

12-10 12:00:31.558: I/Ads(30363): adRequestUrlHtml: <html><head><script ....... 

12-10 12:00:32.085: I/Ads(30363): Received ad url: <"url":  .......... 

12-10 12:00:33.191: I/Ads(30363): onReceiveAd()

Although LogCat shows that AdMob refreshes Ads but the same Add (the Add which was loaded very first time) is shown on the device.

Is there anything needs to be done on Java side.

UPDATE

Advertise.xml

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <com.google.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res/com.becomputer06.vehicle.diary.free"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ads:adUnitId=""
        ads:adSize="BANNER"
        ads:loadAdOnCreate="true"
    />

</LinearLayout>

AndroidMenifest

<manifest
    xmlns:android="http://schemas.android.com/apk/res/android" package="com.becomputer06.vehicle.diary.free"
    android:versionCode="2"
    android:versionName="1.0.1.FREE">
           ........
</manifest>

The result of the code listed above (Compilation Errors):-

Description Resource    Path    Location    Type
error: No resource identifier found for attribute 'adSize' in package 'com.becomputer06.vehicle.diary.free' advertise.xml   /vehicle-diary-free/res/layout  line 5  Android AAPT Problem
error: No resource identifier found for attribute 'adUnitId' in package 'com.becomputer06.vehicle.diary.free'   advertise.xml   /vehicle-diary-free/res/layout  line 5  Android AAPT Problem
error: No resource identifier found for attribute 'loadAdOnCreate' in package 'com.becomputer06.vehicle.diary.free' advertise.xml   /vehicle-diary-free/res/layout  line 5  Android AAPT Problem
R cannot be resolved to a variable  

Upvotes: 3

Views: 8123

Answers (3)

Pranam Shetty
Pranam Shetty

Reputation: 1

I had a similar problem..updating the admob SDK to the latest version resolved the issue

Upvotes: 0

user1085384
user1085384

Reputation:

In the Admob website i think you have register your application by giving the package name. After that you need to take the publisher id from the website and give it in the adUnitId in the xml .

In the java code:

    AdView adview = (AdView)findViewById(R.id.adView);
    AdRequest re = new AdRequest();
    re.setGender(AdRequest.Gender.FEMALE); 
    adview.loadAd(re);   

In the xml:

 <LinearLayout android:id="@+id/LinearLayout02" android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:orientation="vertical" >
    <com.google.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res/com.xxxx" (com.xxx---> your application package name)
        android:id="@+id/adView"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        ads:adSize="BANNER"
        android:background="#4876FF"
        ads:adUnitId=" "

        />
</LinearLayout>

In the Admob website, go to settings and change the refresh rate to 12 seconds. Please click this option also "Use Google ads and Google certified ad networks to improve fill rate". I think this will clear you problem

In the res folder--->under "values" you need to add new xml named attrs.xml In that you need to add

     <?xml version="1.0" encoding="utf-8"?>
     <resources>
     <declare-styleable name="com.google.ads.AdView">
     <attr name="adSize">
       <enum name="BANNER" value="1"/>
       <enum name="IAB_MRECT" value="2"/>
       <enum name="IAB_BANNER" value="3"/>
       <enum name="IAB_LEADERBOARD" value="4"/>
    </attr>
    <attr name="adUnitId" format="string"/>
   </declare-styleable>
   </resources>

Upvotes: 2

Eric Leichtenschlag
Eric Leichtenschlag

Reputation: 8931

I am making the assumption here that you include your actual adUnitId in your XML definition. Otherwise you wouldn't be receiving ads.

Note that you're in test mode. By specifying ads:testDevices="TEST_EMULATOR", you're asking the emulator to send you test ads. When you request an ad in test mode, you will get the same ad back every time. Try removing that parameter, or better yet try debugging on your device, and see if you get a different result.

Upvotes: 3

Related Questions