Scaling of ads and ads are showing up in the emulator but not on the device

604 views
Skip to first unread message

Martin

unread,
Nov 3, 2011, 10:54:57 AM11/3/11
to Google AdMob Ads Developers
Dear all,

I have two questions regarding Admob for Android.

First, I get it run on the emulator but have the problem that the ad
is always scaled to the full width. Here's a screenshot from a 480x800
resolution:

http://www.xaron.net/dl/monkey/admob4.png

I'd like it to have original sized, so it should have 320x50 px.

I use the following XML:

main.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/lib/com.google.ads"

android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<view class="${APP_PACKAGE}.MonkeyGame$MonkeyView"
android:id="@+id/monkeyview"
android:keepScreenOn="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:loadAdOnCreate="true"
ads:adUnitId="a14*************"
ads:testDevices="TEST_EMULATOR"
ads:adSize="BANNER"
/>
</RelativeLayout>

Secondly I see the ad in the emulator but not on the real device....

Thanks!

Eric Leichtenschlag

unread,
Nov 3, 2011, 1:11:45 PM11/3/11
to google-adm...@googlegroups.com
Hello Martin,

The size of the ad that the SDK takes in is a density independent size (dp).  This way, no matter what density device your app runs on, the size of the ad will look the same on the device.  If we didn't scale the image at all, it would look full width on a medium density device, only 2/3 width on your device, and it would be too big for a low density device!  That would be a pain for the developer to manage.

Your second issue is likely a no fill on the device.  Because you specified 'ads:testDevices="TEST_EMULATOR"' in your XML, you're getting test ads on the emulator, but on the device you are requesting real ads.  Check the logcat output to see if you get an error message "Ad Request successful, but no ad returned due to lack of inventory."  An ad doesn't return 100% of the time, and itsometimes takes a while for new publisher ids to start serving real ads.  You can improve your fill rate, however, by enabling AdSense backfill on the AdMob UI.

Cheers,
Eric, AdMob SDK Support


Martin Leidel

unread,
Nov 3, 2011, 2:31:35 PM11/3/11
to google-adm...@googlegroups.com

Hello Eric, thanks for that answer!

Regarding the first problem: So an ad will always fill the same space percent wise of the screen? That makes sense indeed, even though the ad looks huge then on my Desire HD. I just had the impression that a banner will always have a size of 320x50 pixel but on a device with 800x480 it will have a width of 480 and a height of 75 (if I do the math right?)?

I will check the log regarding the second issue, thanks for the hint!

Cheers - Martin

Martin

unread,
Nov 4, 2011, 8:42:11 AM11/4/11
to Google AdMob Ads Developers
Oh and by the way I removed that testDevice line...

THANKS!

Martin

unread,
Nov 4, 2011, 9:01:18 AM11/4/11
to Google AdMob Ads Developers
Nevermind got it to work. My problem was that I use a custom ROM which
had an ad blocker installed...

So I've downloaded AdFree and reverted the host file and voila,
everything's fine now!

Martin

unread,
Nov 4, 2011, 8:16:04 AM11/4/11
to Google AdMob Ads Developers
Alright, I checked the log and that is what it says:

To me it seems that something's wrong with my account id? But I double
checked it, it is the same as I can see in Admob (this a14ea7c...
number)


11-04 13:12:21.070 I/Ads (26361): To get test ads on this device,
call adRequest.addTestDevice("E4FC29FD5095EB1A775D1E833AD4E608");
11-04 13:12:21.130 W/AdsProvider(12772): No active account or
specified account could not be found; aborting
11-04 13:12:21.230 I/Ads (26361): adRequestUrlHtml:
<html><head><script src="http://media.admob.com/sdk-core-v40.js"></
script><script>AFMA_buildAdURL({"preqs":1,"u_sd":
1.5,"slotname":"a14************","u_w":
320,"msid":"com.cobblecrowd.blottypots","js":"afma-sdk-a-
v4.3.1","mv":"8007005.com.android.vending","isu":"E4FC29FD5095EB1A775D1E833AD4E608","cipa":
1,"format":"320x50_mb","net":"ed","app_name":"1.android.com.cobblecrowd.blottypots","hl":"de","u_h":
533,"u_audio":3});</script></head><body></body></html>
11-04 13:12:23.278 I/Ads (26361): Received ad url: <"url": "http://
googleads.g.doubleclick.net:80/mads/gma?
preqs=1&u_sd=1.5&slotname=a14************&u_w=320&msid=com.cobblecrowd.blottypots&js=afma-
sdk-a-
v4.3.1&mv=8007005.com.android.vending&isu=E4FC29FD5095EB1A775D1E833AD4E608&cipa=1&format=320x50_mb&net=ed&app_name=1.android.com.cobblecrowd.blottypots&hl=de&u_h=533&u_audio=3&u_so=p&output=html&region=mobile_app&u_tz=-60&ex=1&client_sdk=1&askip=1&pto=0",
"afmaNotifyDt": "null">
11-04 13:12:23.288 W/Ads (26361): IOException connecting to ad
url.
11-04 13:12:23.288 W/Ads (26361): java.net.ConnectException:
googleads.g.doubleclick.net/127.0.0.1:80 - Connection refused
11-04 13:12:23.288 W/Ads (26361): at
org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:
210)
11-04 13:12:23.288 W/Ads (26361): at
org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:
440)
11-04 13:12:23.288 W/Ads (26361): at
java.net.Socket.connect(Socket.java:1013)
11-04 13:12:23.288 W/Ads (26361): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:
75)
11-04 13:12:23.288 W/Ads (26361): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:
48)
11-04 13:12:23.288 W/Ads (26361): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection
$Address.connect(HttpConnection.java:322)
11-04 13:12:23.288 W/Ads (26361): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:
89)
11-04 13:12:23.288 W/Ads (26361): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:
285)
11-04 13:12:23.288 W/Ads (26361): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:
267)
11-04 13:12:23.288 W/Ads (26361): at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:
205)
11-04 13:12:23.288 W/Ads (26361): at
com.google.ads.b.run(SourceFile:280)
11-04 13:12:23.288 W/Ads (26361): at
java.lang.Thread.run(Thread.java:1027)
11-04 13:12:23.288 I/Ads (26361): onFailedToReceiveAd(A network
error occurred.)

On 3 Nov., 18:11, Eric Leichtenschlag <eleichtens...@google.com>
wrote:

Jim

unread,
Nov 4, 2011, 2:19:23 PM11/4/11
to Google AdMob Ads Developers
Martin,

This line:

11-04 13:12:23.288 W/Ads (26361): java.net.ConnectException:
googleads.g.doubleclick.net/127.0.0.1:80 - Connection refused

means that you get an Ad URL back, but haven't removed the ad blocker
completely. It says the "doubleclick" URL where the ad resides is
routing to 127.0.0.1 - which is localhost... the device itself.

Check /etc/hosts to see if you have doubleclick routing to 127.0.0.1 -
remove any lines with "AdMob" or "doubleclick" and it should help.

-Jim

On Nov 4, 7:16 am, Martin <martin.lei...@gmail.com> wrote:
> Alright, I checked the log and that is what it says:
>
> To me it seems that something's wrong with my account id? But I double
> checked it, it is the same as I can see in Admob (this a14ea7c...
> number)
>
> 11-04 13:12:21.070 I/Ads     (26361): To get test ads on this device,
> call adRequest.addTestDevice("E4FC29FD5095EB1A775D1E833AD4E608");
> 11-04 13:12:21.130 W/AdsProvider(12772): No active account or
> specified account could not be found; aborting
> 11-04 13:12:21.230 I/Ads     (26361): adRequestUrlHtml:
> <html><head><script src="http://media.admob.com/sdk-core-v40.js"></
> script><script>AFMA_buildAdURL({"preqs":1,"u_sd":
> 1.5,"slotname":"a14************","u_w":
> 320,"msid":"com.cobblecrowd.blottypots","js":"afma-sdk-a-
> v4.3.1","mv":"8007005.com.android.vending","isu":"E4FC29FD5095EB1A775D1E833 AD4E608","cipa":
> 1,"format":"320x50_mb","net":"ed","app_name":"1.android.com.cobblecrowd.blo ttypots","hl":"de","u_h":
> 533,"u_audio":3});</script></head><body></body></html>
> 11-04 13:12:23.278 I/Ads     (26361): Received ad url: <"url": "http://
> googleads.g.doubleclick.net:80/mads/gma?
> preqs=1&u_sd=1.5&slotname=a14************&u_w=320&msid=com.cobblecrowd.blot typots&js=afma-
> sdk-a-
> v4.3.1&mv=8007005.com.android.vending&isu=E4FC29FD5095EB1A775D1E833AD4E608& cipa=1&format=320x50_mb&net=ed&app_name=1.android.com.cobblecrowd.blottypot s&hl=de&u_h=533&u_audio=3&u_so=p&output=html&region=mobile_app&u_tz=-60&ex= 1&client_sdk=1&askip=1&pto=0",
> org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConn...
> 285)
> 11-04 13:12:23.288 W/Ads     (26361):   at
> org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnect...
> 267)
> 11-04 13:12:23.288 W/Ads     (26361):   at
> org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl...
Reply all
Reply to author
Forward
0 new messages