Admob no longer displays text banners

On the Admob web interface, we selected text banners but untested graphic banners for our application. This works until we update the SDK tools, build tools, platform tools and SDK platforms. Now our application only shows graphic banners that I obviously don't want to receive. We have not changed the ad related code, and we have also not changed the Admob settings in the web interface.

To find the problem, we created a new test project and went through the official instructions on how to set up Admob step by step. Same problem! Here is the resulting code:

Here is the declaration (fragment_ad.xml) :

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-XXXXXXXXXXXXXXXX">
    </com.google.android.gms.ads.AdView>

</RelativeLayout>

      

And this is the test activity (MainActivity.java) :

package com.example.myadapp;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    /**
     * A placeholder fragment containing a simple view.
     */
    public static class PlaceholderFragment extends Fragment {

        public PlaceholderFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_main, container,
                    false);
            return rootView;
        }
    }

    public static class AdFragment extends Fragment {
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            return inflater.inflate(R.layout.fragment_ad, container, false);
        }

        @Override
        public void onActivityCreated(Bundle bundle) {
            super.onActivityCreated(bundle);
            AdView mAdView = (AdView) getView().findViewById(R.id.adView);
            AdRequest adRequest = new AdRequest.Builder().build();
            mAdView.loadAd(adRequest);
        }
    }
}

      

... with layout file activity_main.xml :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    tools:ignore="MergeRootFrame" >

    <fragment 
        android:id="@+id/placeholder"
        android:name="com.example.myadapp.MainActivity$PlaceholderFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/adFragment" />

    <fragment
        android:id="@+id/adFragment"
        android:name="com.example.myadapp.MainActivity$AdFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />
</RelativeLayout>

      

Finally, the AndroidManifest.xml app :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myadapp"
    android:versionCode="1"
    android:versionName="1.0" >

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

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

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

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

      

Here is the LogCat we get on the AVD with the GoogleAPI API19:

12-31 09:12:26.251: I/Ads(2403): Starting ad request.
12-31 09:12:26.251: I/Ads(2403): Use AdRequest.Builder.addTestDevice("B3EEABB8EE11C2BE770B684D95219ECB") to get test ads on this device.
12-31 09:12:26.411: D/gralloc_goldfish(2403): Emulator without GPU emulation detected.
12-31 09:12:26.751: D/dalvikvm(2403): DexOpt: --- BEGIN 'ads-96486195.jar' (bootstrap=0) ---
12-31 09:12:26.951: D/dalvikvm(2403): DexOpt: --- END 'ads-96486195.jar' (success) ---
12-31 09:12:26.951: D/dalvikvm(2403): DEX prep '/data/data/com.example.myadapp/cache/ads-96486195.jar': unzip in 172ms, rewrite 204ms
12-31 09:12:31.271: D/dalvikvm(2403): GC_FOR_ALLOC freed 262K, 10% free 3566K/3936K, paused 7ms, total 8ms
12-31 09:12:31.271: I/dalvikvm-heap(2403): Grow heap (frag case) to 4.659MB for 1127532-byte allocation
12-31 09:12:31.291: D/dalvikvm(2403): GC_FOR_ALLOC freed 1K, 8% free 4666K/5040K, paused 16ms, total 16ms
12-31 09:12:31.941: I/chromium(2403): [INFO:simple_index_file.cc(397)] Simple Cache Index is being restored from disk.
12-31 09:12:33.091: I/Ads(2403): Scheduling ad refresh 30000 milliseconds from now.
12-31 09:12:33.091: I/Ads(2403): Ad finished loading.

      

We are importing the google-play-services-lib into Eclipse as described here .

The problem occurs on both Android 4.0 and 4.4 as well as the emulator, and both with and without adding a device as a test device using com.google.android.gms.ads.AdRequest.Builder.addTestDevice(String deviceId)

Does anyone face the same problem?

EDIT: Regarding the test project, sometimes a text banner appears randomly. It seems like AdMob doesn't really care about the customization done in the web interface ...

+3


source to share





All Articles