I want to use xml to add a banner ad to my app. To understand how to do this, I read through the Google AdMob Ads Android Banner XML tutorial. There's even example code. However, the example project doesn't display ads on my device (a Motorola xt720). I get nothing relevant in LogCat.
If I go to project settings and remove the 4.0.4 jar and add the 4.1.0 jar that I downloaded with Android SDK and AVD Manager (downloaded "Google Admob Ads Sdk package, revision 2" and the file is android-sdk-linux_86/extras/google/admob_ads_sdk/GoogleAdMobAdsSdk-4.1.0.jar
), then I get this in LogCat.
ERROR/Ads(4486): AdView missing required XML attribute "adSize".
INFO/Ads(4486): To get test ads on this device, call adRequest.addTestDevice("00000000000000000000000000000000");
I make that change:
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice("00000000000000000000000000000000");
adView.loadAd(adRequest);
And now I get this:
ERROR/Ads(5018): AdView missing required XML attribute "adSize".
WARN/Ads(5018): Invalid unknown request error: Cannot determine request type. Is your ad unit id correct?
INFO/Ads(5018): onFailedToReceiveAd(Invalid Google Ad request.)
If I edit main.xml to fix the ads:adUnitId
to be the value I have in my admob account, I still get the same error. As you can see, I am setting my adSize:
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="000000000000000"
ads:adSize="BANNER" />
So in summary:
- I fixed the library version
- I added my test device
- I set my ads:adUnitId
But I still get AdView missing required XML attribute "adSize"
What am I doing wrong?