sandalone
sandalone

Reputation: 41749

No AdMob ads show up?

I am at my wits' end. I have a special LinearLayout for ads

<LinearLayout
            android:id="@+id/layout1"
            android:layout_width="fill_parent"
            android:layout_height="52dp"
            >
</LinearLayout>

I fill it with ads from the code

adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);
LinearLayout bout = (LinearLayout) findViewById(R.id.layout1);
bout.addView(adView);
// Initiate a generic request to load it with an ad
adView.loadAd(new AdRequest());

Manifest file looks like this

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

<activity android:name="com.google.ads.AdActivity"
          android:configChanges="keyboard|keyboardHidden|orientation"
/>

And the JAR GoogleAdMobAdsSdkAndroid-4.1.1 is added to the path.

No ads EVER show up. In Logcat I see that

08-23 12:03:04.527: WARN/Ads(28980): IOException connecting to ad url.
08-23 12:03:04.527: INFO/Ads(28980): onFailedToReceiveAd(A network error occurred.)

I test this on a real device.

Any suggestions?

Upvotes: 0

Views: 2503

Answers (2)

sandalone
sandalone

Reputation: 41749

It seems that Manifest file still NEEDS meta data, although the official docs do not say anything about it. So in the manifest file add the meta data (besides other data) and the ads will show up

<application android:label="App Name" android:icon="@drawable/icon">
        <meta-data
            android:name="ADMOB_PUBLISHER_ID"
            android:value="XXXXXXXXXXXXXX"
            >
        </meta-data>
...

I came up to this conclusion by implementing AdListener and adding Log messages into it. I suggest you do the same in case you need to closely investigate what is going on when an ad has been received.

Upvotes: 0

Aracem
Aracem

Reputation: 7207

With the latest version of admob (4.1 i think) the easy form to put admob ads is with xml. You only should put :

//At the beginin of the xml
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

        <com.google.ads.AdView
            android:id="@+id/Ads"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"

            ads:adUnitId="a14daeadccXXXXX"
            ads:adSize="BANNER"
            ads:loadAdOnCreate="true"/> 

Then the permision and remember dont put padding to de linearlayout or the ads dont appear.

Upvotes: 1

Related Questions