problem with 4.1.0 - "Adview missing required XML attribute "adsize""

9131 views
Skip to first unread message

Rob

unread,
May 11, 2011, 11:26:05 PM5/11/11
to Google AdMob Ads Developers
I was using 4.0.4 with no issues and then updated on Admob to 4.1.0.
I have the adviews set up in the layout XML (my ad unit is changed
obviously and I know it's valid because it's in a live app that is
serving ads with no problems) :

<com.google.ads.AdView android:id="@+id/topad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId="1234"
ads:adSize="BANNER"/>

And the Adview is defined in attrs.xml as:

<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>

Logcat doesn't give me much:

05-11 23:14:03.182: WARN/Ads(17648): Invalid unknown request error:
Cannot determine request type. Is your ad unit id correct?
05-11 23:14:03.185: INFO/Ads(17648): onFailedToReceiveAd(Invalid
Google Ad request.)
05-11 23:20:52.138: ERROR/Ads(17800): AdView missing required XML
attribute "adSize".
05-11 23:20:52.205: ERROR/Ads(17800): AdView missing required XML
attribute "adSize".


This was working perfectly fine before with 4.0.4...have I missed an
instruction somewhere? All I thought that was necessary was to drop
the new JAR in the build path... please help.

Thanks!

Join

unread,
May 11, 2011, 11:41:02 PM5/11/11
to Google AdMob Ads Developers
Same problem in my development.

Rob Franz

unread,
May 12, 2011, 10:15:46 AM5/12/11
to google-adm...@googlegroups.com
Anyone else see this?  I have also sent this on to Admob's support (not sure if it all goes to the same place anyway).  Would it be possible to get access to the old version of the JAR?  I foolishly seem to have deleted 4.0.4 :(

chis

unread,
May 12, 2011, 11:34:47 AM5/12/11
to Google AdMob Ads Developers
I'm having the same issue. Tried adding this from scratch and my app
only shows "AdView missing required XML
attribute "adSize"." where the ad should be. :-( I might go back to
the AdMob SDK from the admob-sdk-android_20101109 release...

Rob Franz

unread,
May 12, 2011, 11:39:38 AM5/12/11
to google-adm...@googlegroups.com
4.0.4 seems to be working with no problems for me... I may just go back to that as well.

Google - anything from you guys?  

Scott Culverhouse

unread,
May 12, 2011, 1:35:34 PM5/12/11
to Google AdMob Ads Developers
On May 12, 4:39 pm, Rob Franz <rob.fr...@gmail.com> wrote:
> 4.0.4 seems to be working with no problems for me... I may just go back to
> that as well.
>
> Google - anything from you guys?


I can confirm this issue also.

If you still want the 4.0.4 jar I can upload however it's included in
example zips inside the libs directory.

~

Rob Franz

unread,
May 12, 2011, 1:37:01 PM5/12/11
to google-adm...@googlegroups.com
Thanks Scott.  I still happen to have 4.0.4 sitting around (thought I deleted it) so I'm going to stick with that one.  

-r

Tim

unread,
May 12, 2011, 4:13:29 PM5/12/11
to Google AdMob Ads Developers
Hi everyone,

Sorry for the inconvenience. We haven't had a chance to update all of
our documentation fully yet. 4.1.0 made some changes to the way that
XML layouts work. In particular, you shouldn't need attrs.xml anymore.
Try the following and let me know if it works (or more importantly if
it doesn't):

1) Remove attrs.xml (or if you need it for your own custom attributes,
remove the parts related to AdViews).
2) Change the namespace in your layout from xmlns:ads="http://
schemas.android.com/apk/res/com.your.packagename"
to xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

Also, in the simplest of cases, where your code simply does
AdView.loadAd(new AdRequest()), there's a new XML attribute to make
your code even simpler. Adding ads:loadAdOnCreate="true" should call
loadAd(new AdRequest()) for you when the ad is inflated from the XML.
This means that the simplest of cases just got simpler because it
requires no code at all (no finding the view from the layout just to
call loadAd with a blank ad request). Obviously keep in mind though
that using this method means you have less control over your ads like
when requests occur, and what goes in them.

We think this will be easier in the long run since you won't have to
create the attrs.xml file. Again, sorry for the inconvenience and
thanks for your patience.

Thanks,
-Tim

Rob Franz

unread,
May 12, 2011, 4:20:12 PM5/12/11
to google-adm...@googlegroups.com
Thanks Tim...I put 4.1.0 back in, followed these steps (kept attrs.xml and removed the adviews stuff), and everything looks good now.

-rob

Tim

unread,
May 12, 2011, 4:27:59 PM5/12/11
to Google AdMob Ads Developers
Rob,

That's good to hear. We're trying to keep the documentation up to
date, but we figured you'd rather get the code as soon as it was
available since it fixes quite a few bugs rather than wait for us to
sift through all of our documentation updating it. Sorry again for the
inconvenience and thanks for testing it so quickly!

Another update on the XML attributes is that you should also be able
to use string resources now (e.g. "@string/admob_id").

Thanks,
-Tim

ez

unread,
May 12, 2011, 4:43:16 PM5/12/11
to Google AdMob Ads Developers
Hi Tim

Thanks

We got it to work. But we cannot remove attrs.xml file.

The key seems to be you second point.

2) Change the namespace in your layout from xmlns:ads="http://
schemas.android.com/apk/res/com.your.packagename"
to xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

Thanks

grndvl1

unread,
May 15, 2011, 12:04:39 PM5/15/11
to Google AdMob Ads Developers
Got the new update and removed the attrs properties for admob and also
removed all loads from code using the ads:loadAdOnCreate="true". Then
changed the reference to the a xmlns with xmlns:ads="http://
schemas.android.com/apk/lib/com.google.ads". Application loads now
0.10 secs faster and seen a reduction in load size of app to now that
every page doesn't explicitly load the adMob classes. Thanks!

Whitecat Software

unread,
May 15, 2011, 1:42:54 PM5/15/11
to Google AdMob Ads Developers
Well it kind of works. It now displays ads correctly, but not all ads
are the same size even though the BANNER size is set. Some ads come
back about half size - these were ads that used to fill the whole
BANNER ie: screen width * 40px.

Whitecat Software

unread,
May 15, 2011, 1:45:43 PM5/15/11
to Google AdMob Ads Developers
Edit I meant 50px. And the E-Bay for android ad is an example of one
that comes back half size - the graphic one is half size, but the text
version is full size.

On May 15, 6:42 pm, Whitecat Software

Apichai C.

unread,
May 16, 2011, 2:03:20 AM5/16/11
to Google AdMob Ads Developers
Thanks. It works.

Ebenezer

unread,
May 12, 2011, 12:55:51 PM5/12/11
to Google AdMob Ads Developers
Have exactly the same problem.
I am using version 4.02 now until this buf is fixed, because I deleted
4.04.

Sargius

unread,
May 17, 2011, 10:49:40 AM5/17/11
to Google AdMob Ads Developers
Dear Tim, I am trying to include AdMob in Android Live Wallpaper
Settings screen and it seems to me that I have all possibles problems
which I could have. If you have a sample of that applicatio, a
workable one, please send me, it will be a nice solution of all
problems. Thank you very much in advance!

DraganA

unread,
May 18, 2011, 6:21:45 AM5/18/11
to Google AdMob Ads Developers
I'm still having problems, even after doing what Tim said, the problem
shows in Eclipse graphical designer whey using Admob xml layout.
Something to do with XML parser, and not being able to instantiate
Admob class, and it only seems to affect graphical layouts for <
Android 2.3

Tim

unread,
May 18, 2011, 3:17:08 PM5/18/11
to Google AdMob Ads Developers
DraganA,

What type of error are your receiving? What does your layout look
like? Please provide more information so that we can try to reproduce
the issue.

Thanks,
-Tim

kerul

unread,
May 19, 2011, 2:46:45 AM5/19/11
to Google AdMob Ads Developers
For anyone who seems lost, do visit my simple tutorial at
http://blog.kerul.net/2011/05/installing-google-admob-into-android.html
...

This tutorial is for installing admob sdk 4.1.0 in android. Hope it
helps...

DraganA

unread,
May 19, 2011, 4:42:32 AM5/19/11
to Google AdMob Ads Developers
Hi Tim,

After following the steps you specified, I open an xml layout file in
Graphical layout tab, with Admob view in there. By default it opens
Android 3.0 layout version and that works fine. Android 2.3 also works
fine, but when I select Android 2.2 Layout I get error. This is the
copy of the error log.


!ENTRY com.android.ide.eclipse.adt 4 0 2011-05-19 09:39:04.906
!MESSAGE login.xml: Parser is not a BridgeXmlBlockParser!

!ENTRY com.android.ide.eclipse.adt 4 0 2011-05-19 09:39:04.906
!MESSAGE com.google.ads.AdView failed to instantiate.
!STACK 0
java.lang.NullPointerException
at android.view.View.<init>(View.java:1880)
at android.widget.TextView.<init>(TextView.java:327)
at android.widget.TextView.<init>(TextView.java:321)
at android.widget.TextView.<init>(TextView.java:316)
at com.google.ads.AdView.a(Unknown Source)
at com.google.ads.AdView.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:
39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.instantiateClass(ProjectCallback.java:
337)
at
com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.loadView(ProjectCallback.java:
132)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:
198)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:
126)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:296)
at com.android.layoutlib.bridge.Bridge.computeLayout(Bridge.java:397)
at
com.android.ide.common.rendering.LayoutLibrary.createLegacySession(LayoutLibrary.java:
404)
at
com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:
285)
at
com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:
1506)
at
com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:
1312)
at
com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:
1043)
at
com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart
$ConfigListener.onConfigurationChange(GraphicalEditorPart.java:488)
at
com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite.onRenderingTargetChange(ConfigurationComposite.java:
1838)
at
com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite.access
$10(ConfigurationComposite.java:1806)
at
com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite
$8.widgetSelected(ConfigurationComposite.java:501)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:
228)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:
3910)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3503)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:
2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:
332)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:
493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:
149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:
113)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:
194)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:
110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:
79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:
368)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:
179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)

Tim

unread,
May 19, 2011, 6:14:13 PM5/19/11
to Google AdMob Ads Developers
DraganA,

Thanks for the additional info. I've found the error and it should be
corrected in the next release. This error only should only affect the
graphical layout editor because it attempts to insert a TextView that
says "Ads by Google" where the ad should be, but it is initialized in
a way that causes it to crash on Android 2.2. Your ads in your app
should be fine.

Thanks,
-Tim

kreeda

unread,
May 19, 2011, 11:47:15 PM5/19/11
to Google AdMob Ads Developers
Hi Tim,

I am having a issue with point 2 that is mentioned in you post. : "2)
Change the namespace in your layout from xmlns:ads="http://
schemas.android.com/apk/res/com.your.packagename"
to xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

the xml for my layout is as follows..

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#FF0000"
com.google.ads.adSize="BANNER"/>

<com.Kreeda.MainView
android:id="@+id/themain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/ad"/>
</RelativeLayout>

is there a way to still use this, or do i need to start from the
beginning?

Tim

unread,
May 20, 2011, 12:10:26 AM5/20/11
to Google AdMob Ads Developers
kreeda,

Try adding the following line
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
after the line
xmlns:android="http://schemas.android.com/apk/res/android"
in your RelativeLayout.

Then, change com.google.ads.adSize="BANNER" to ads:adSize="BANNER" in
AdView. And the last thing is to add ads:adUnitId="your_admob_id" to
AdView. I think that should work.

Thanks,
-Tim

Prateek

unread,
May 20, 2011, 4:36:13 AM5/20/11
to Google AdMob Ads Developers
Hi Tim,
Thanks for your prompt responses. I am facing a weird issue in which
the ad doesn't show up if I put it at the bottom of a LinearLayout or
RelativeLayout.

It shows up perfectly when I place it on top. I get a warning in
LogCat that says "Not enough space to show ad! Wants: <480, 75>, Has:
<480, 64>"

Following is the stripped down code. Basically there is a root
linearlayout containing four children: RelativeLayout (of weight 0.9),
a TextView, an Ad divider image and AdView (of weight 0.1).

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
xmlns:ads="http://schemas.android.com/apk/res/
mypackage"
android:id="@+id/rootLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<RelativeLayout
android:id="@+id/headerRelativeLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.9">

<!--Bunch of images and list under Relative layout-->

<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>

<TextView
android:id="@+id/someText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="7dip"/>

<ImageView
android:id="@+id/adDividerImageView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>

<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.1"
ads:adUnitId="my_unit"
ads:adSize="BANNER"/>
</LinearLayout>

and my onCreate():

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

AdView adView = (AdView) this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest();

adView.setAdListener(new AdViewListener(this));
adView.loadAd(adRequest);

Please advise what I am doing wrong. I have been stuck on this for
past 3 days.

Thanks!

Prateek

kreeda

unread,
May 20, 2011, 1:21:54 PM5/20/11
to Google AdMob Ads Developers
Thank you for the quick responce. You made my day! thanks again.
> > beginning?- Hide quoted text -
>
> - Show quoted text -

paul sohier

unread,
May 31, 2011, 10:14:51 AM5/31/11
to Google AdMob Ads Developers
Hi Tim,

Is there any chance the documentation can be updated anytime soon?
Right now it is very hard to get stuff working, while it should not be
that difficult to update the site.

Thanks.
Paul.

wes

unread,
May 31, 2011, 3:38:21 PM5/31/11
to google-adm...@googlegroups.com
Prateek,

Have you tried hard-coding the AdView's layout_height as 75dip?

Cheers,
Wes

Rogério Guimarães

unread,
Jun 9, 2011, 9:59:50 PM6/9/11
to Google AdMob Ads Developers
Hi Tim,

Please help me.

I did every step you wrote below and my application is still showing
"AdView missing required XML attribute adSize".

I read each post in the forum and I cannot fix the problem.

My App is API Level 7 with Google API.
My Eclipse run in Mac Os

Regards,

Rogerio

Tommy

unread,
Jun 9, 2011, 10:22:30 PM6/9/11
to Google AdMob Ads Developers
I am having problems with the new 4.1.0 sdk with banner ads showing
half the size. Im not sure but it seems to be something with using
the new namespace xmlns:ads="http://schemas.android.com/apk/lib/
com.google.ads" in my layout xml instead of the old namespace
xmlns:ads="http://schemas.android.com/apk/res/com.your.packagename"
because the old namespace uses the attrs.xml file assigns adSize for
"BANNER" with a value of "1".

I don't know if this is the problem because of using namespace
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" with no
attrs.xml file. It only happens to banner ads. Text ads show up with
correct size.

Please fix. Can't update my app until ads shows correctly.

Ishwarya Prasanna

unread,
Sep 19, 2016, 8:17:52 AM9/19/16
to Google Mobile Ads SDK Developers
I am new to android development.i have created my new app with admob syncing.kindly help me to solve this issue.i am not getting ad in Test ad place.instead i am getting Required XML attribute "adsize" missing in adplace.

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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.shakthi.preg_zlite.MainActivity">

<RelativeLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#FFFFFF"
android:gravity="center" >



<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/adview1"
            android:layout_width="fill_parent"
android:layout_height="wrap_content"
            ads:adUnitId="ADUNIT"
ads:adsSize="BANNER"
/>

</RelativeLayout>
<GridView
android:id="@+id/grid"
android:layout_width="match_parent"
android:stretchMode="columnWidth"
android:layout_marginTop="50dp"
android:numColumns="2"
android:horizontalSpacing="15dp"
android:layout_height="match_parent"
android:padding="25dp"
>
</GridView>
</RelativeLayout>

JAVA:

package com.shakthi.preg_zlite;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;

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

public class MainActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch(position) {
case 0:
Intent ppp = new Intent();
ppp.setClass(MainActivity.this, Pregnancyplanner.class);
startActivity(ppp);
break;
case 1:
Intent cc = new Intent();
cc.setClass(MainActivity.this, Duedatecalc.class);
startActivity(cc);
break;
case 2:
break;
case 3:

break;
default:
break;
}

}

String[] title = { "Pregnancy planner","Due date calculator","Basic pregnancy info","Reminder" };
int[] icon={R.mipmap.prepregnancyplanner,R.mipmap.duedatecalc,R.mipmap.laboursign,R.mipmap.reminder};
GridView grid;

@Override
protected void onCreate(Bundle savedInstanceState) {
String AD_UNIT_ID = "XXXXX";
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AdView adView = (AdView) this.findViewById(R.id.adview1);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(AD_UNIT_ID);
adView.loadAd(new AdRequest.Builder().build());
grid = (GridView) findViewById(R.id.grid);
CustomGrid adapter=new CustomGrid();
grid.setAdapter(adapter);
grid.setOnItemClickListener(this);
}
class CustomGrid extends BaseAdapter {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater
.from(getApplicationContext());
Viewholder holder = null;
if (convertView == null) {
holder = new Viewholder();
convertView = inflater.inflate(R.layout.custom_list, parent,
false);
holder.name = (TextView) convertView.findViewById(R.id.title);


holder.image = (ImageView) convertView.findViewById(R.id.image);
convertView.setTag(holder);

} else {
holder = (Viewholder) convertView.getTag();
}
holder.name.setText(title[position]);
holder.image.setImageResource(icon[position]);


return convertView;

}

@Override
public int getCount() {
// TODO Auto-generated method stub
return 4;
}

@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}

@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
class Viewholder {
ImageView image;
TextView name;

}
}


}

APP level gradle:
apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24.0.2"

defaultConfig {
applicationId "com.shakthi.preg_zlite"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.google.android.gms:play-services-ads:9.4.0'
// compile files('libs/GoogleAdMobAdsSdk-6.3.0.jar')
}

Project level gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

On Thursday, May 12, 2011 at 8:56:05 AM UTC+5:30, Rob wrote:
I was using 4.0.4 with no issues and then updated on Admob to 4.1.0.
I have the adviews set up in the layout XML (my ad unit is changed
obviously and I know it's valid because it's in a live app that is
serving ads with no problems) :

<com.google.ads.AdView android:id="@+id/topad"
                         android:layout_width="fill_parent"
                         android:layout_height="wrap_content"
                         ads:adUnitId="1234"
                         ads:adSize="BANNER"/>

And the Adview is defined in attrs.xml as:

<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>

Logcat doesn't give me much:

05-11 23:14:03.182: WARN/Ads(17648): Invalid unknown request error:
Cannot determine request type. Is your ad unit id correct?
05-11 23:14:03.185: INFO/Ads(17648): onFailedToReceiveAd(Invalid
Google Ad request.)
05-11 23:20:52.138: ERROR/Ads(17800): AdView missing required XML
attribute "adSize".
05-11 23:20:52.205: ERROR/Ads(17800): AdView missing required XML
attribute "adSize".


Vu Chau (Mobile Ads SDK Team)

unread,
Sep 19, 2016, 12:40:30 PM9/19/16
to Google Mobile Ads SDK Developers
Hi Ishwarya,

You would want to isolate the cause of the problem here. I would eliminate all the code that isn't related to ads to test. 

Also, I'd correct the spelling at ads:adsSize="BANNER" in your AdView's XML.  As a helpful tip, you only need to set the adSize once (either in the Java or in the XML).

Vu Chau
Mobile Ads SDK Team

bana w bas

unread,
Apr 26, 2017, 3:10:41 AM4/26/17
to Google Mobile Ads SDK Developers

1-i finished making my project i tried every way to put admob and

 build app and try it on my phone and it doesn't show the ad can any one help me .





2-and where to add the banner is it in the tabbed activity only or in 

the fragments and in the other activities that contain pdf viewer and web view ??





this is java file .

public class tap extends AppCompatActivity {


private static final String TAG = "tap";

private SectionsPageAdapter mSectionsPageAdapter;
private ViewPager mViewPager ;


@Override
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
setContentView(R.layout.tap);
Log.d(TAG, "onCreate : starting");
mSectionsPageAdapter = new SectionsPageAdapter(getSupportFragmentManager());

// Set up the ViewPager with the section adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
setupViewPager(mViewPager);
TabLayout tablayout = (TabLayout) findViewById(R.id.tabs);
tablayout.setupWithViewPager(mViewPager);
}
private void setupViewPager(ViewPager viewPager) {
SectionsPageAdapter adapter = new SectionsPageAdapter(getSupportFragmentManager());
adapter.addFragment(new pharmacist(),"Ph");
adapter.addFragment(new dentist(),"Dent");
adapter.addFragment(new doctor(),"MD");
adapter.addFragment(new pook(),"on");
viewPager.setAdapter(adapter);

}
}

this is the layout


<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
    android:layout_width="match_parent"
android:layout_height="match_parent"
    android:fitsSystemWindows="true"
tools:context="com.testpharmacist.tap">


<android.support.v4.view.ViewPager
android:id="@+id/container"
        android:layout_width="match_parent"
android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
        android:layout_width="match_parent"
android:layout_height="wrap_content"
        android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">


<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="50dp"
android:layout_height="25dp"
android:layout_marginTop="10dp"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">

</android.support.v7.widget.Toolbar>

<android.support.design.widget.TabLayout
android:id="@+id/tabs"
            android:layout_width="match_parent"
android:layout_height="wrap_content"
            app:layout_scrollFlags="scroll|enterAlways"      />

</android.support.design.widget.AppBarLayout>

</android.support.design.widget.CoordinatorLayout>



 

Joshua Lagonera (Mobile Ads SDK Team)

unread,
Apr 26, 2017, 3:39:13 AM4/26/17
to Google Mobile Ads SDK Developers
Hi there,

Please refrain from re-opening old threads with new issues.

That said, seeing as you have already created your own thread on your issue, I would suggest you continue your discussion from there as this thread is around 7 months old.

Regards,
Joshua Lagonera
Mobile Ads SDK Team
Reply all
Reply to author
Forward
0 new messages