I get a "Required XML attribute "adSize" was missing" when I launch my app. This is written on the screen of my smartphone instead of my banner.
I tried the different solutions founded on stack (like xmlns:ads="http://schemas.android.com/apk/res-auto" instead of xmlns:ads="http://schemas.android.com/apk/libs/com.google.ads" or instead of xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads") but it doesn't work.
Here's my java code (a simple Hello World just to try to implement a banner):
package com.example.publicite;import android.os.Bundle;import android.app.Activity;import android.view.Menu;publicclassMainActivityextendsActivity{@Overrideprotectedvoid onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);}@Overridepublicboolean onCreateOptionsMenu(Menu menu){// Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu);returntrue;}}
Here's my xml file:
and here's my manifest:
I use the google play service lib.
回答1:
Here is a weird answer. I just restarted my eclipse and it stared working. This might help some one.
Just restart eclipse or android studio
回答2:
Try changing your declaration this way:
---- EDIT ----
You can also try to do it programmatically. Simply, instead of an AdView layout item, define a LinearLayout and by code do something like this:
I had the same problem and I corrected it with the xmlns labels. I put two "xmlns:ads" labels (one for "res-auto" in the AdView and other for "tools" in the parent layout). I had to use two labels for "res auto", one with xmlns:app in the FloatingActionButton and other with xmlns:ads in the AdView:
回答4:
change as below ..remove ads:loadAdOnCreate="true"
it solve my problem, i hope it will solve yours :)
回答9:
It turns out that you CANNOT use wrap_content as a size, so you need to give it a size instead. My ads weren't working and after a day of googling I changed my
android:layout_height="wrap_content"
to
android:layout_height="100dp"
and it fixed the issue. P.S. "match_parent" does work (I have that set for my width)
回答10:
Check for DEIVCE_ID_EMULATOR too as in my code I have the following code from following the tutorial from Google:
In my case I was testing it on a real device so it never came up but just gave me the message that the adsize was not set. I ran up an emulator and nkn's solution works perfectly.