Admob + google-play-services_lib : first banner is not showing, but others do.

5,936 views
Skip to first unread message

Sylvain

unread,
Jan 25, 2014, 1:27:39 PM1/25/14
to google-adm...@googlegroups.com
Hello,

I have a problem with the migration from 6.4.1 (.jar) to  "google-play-services_lib" + admob.

I use only the most basic banner (exactly the tutorial Banner I).

With admob 6.4.1, I have no problem.

With "google-play-services_lib" + admob, I have this strange issue : 
All the ads are correctly received (see logcat, + details).
But the first ad is never shown. Second ad, and all afterward, always appear correctly.
I configured the ads to be changed every 60sec, so basically : during the first 60sec, I don't see anything. After 60s, I start to see ads.

=> It looks like the second refresh make the AdView appeared / focused ?.

More details :
All Android SDK and packages are updated to the latest version, I use ndk-r9c, a phone device (nexus5 + normal rom android 4.4).
and target-api=19. I dont use the addTestDevice.

My application is 99% native, but with a thin java layer. I basically use a game library based on egl.


The java parts consists in an activity, with an "AbsoluteLayout" where are added (within the onCreate) two views : a SurfaceView for the native egl stuff, and the AdView.


What I think to be relevant, and what I have done for debugging :
 
- As I said, with admob_6.4.1 (and without Google-play-service), I have no problem. I mean that I see all the ads, from the beginning of the app.
  I have only the modification to migrate from admob_6.4.1 to Google-Play-Services+admob.

- The logcat show that the ad is always correctly received (+ an error of GooglePlayServicesUtil).

- If I changed the AbsoluteView by a RelativeLayout (and permute also the two views, because SurfaceView is fullscree) I see the ads from the beginning (of course this is not the layout exected !)

- If I remove the SurfaceView, I see the correctly ads (but not the game of course)

- If I changed the SurfaceView by a TextView (with lot of text inside). I see correctly the ads over the TextView.

- I tried to use "bringChidToFront" on the AdView, but it does not help.

- I tried to use setZOrderMediaOverlay and setZOrderOnTop on the SurfaceView, but it does not help.

- Something strange. During the first 60s, I see no ad, but If start pressing "home" button -> I see the ad during a fraction of second before the app goes to background.
 If I restore to foreground, I see the ads. (I have the new pause/resume/destroy calls, as required).

- If I use addTestDevice + the correct device_id, I don't see anything. But If I press home+restore, I see the true ad (not the test ad).

- See also the "GooglePlayServicesUtil" message in the Log. I think the lib is correctly installed. I copied the whole folder, to my own place, and referenced it within the project.properties.

- I added some debug message with the "AdListener" (banner II tutorial), I only see "onAdLoaded". No error message.

So, do you have an idea ? What has been changed ? What could I do ?

Thanks,

Sylvain


logcat with : adb shell "setprop log.tag.Ads VERBOSE; logcat Ads:* *:S"


First Ad, but does not appear :

I/Ads     (16333): Use AdRequest.Builder.addTestDevice("0A8EF8E127F7072E941E6D7882BF0E8E") to get test ads on this device.
I/Ads     (16333): Starting ad request.
D/Ads     (16333): Enabling hardware acceleration on an AdView.
D/Ads     (16333): AdLoaderBackgroundTask started.
E/GooglePlayServicesUtil(16333): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
D/Ads     (16333): Fetching ad response from remote ad request service.
E/GooglePlayServicesUtil(16333): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
E/GooglePlayServicesUtil(16333): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
D/Ads     (24313): Binding to the ad request service.
D/Ads     (24313): Starting ad request from service.
D/Ads     (24313): Enabling hardware acceleration on an overlay.
D/Ads     (24313): Getting the ad request URL.
D/Ads     (16333): Received ad response.
D/Ads     (16333): WebView finished loading.
I/Ads     (16333): Scheduling ad refresh 60000 milliseconds from now.
D/Ads     (16333): Pinging Impression URLs.
I/Ads     (16333): Ad finished loading.

The second does appear :

I/Ads     (16333): Starting ad request.
D/Ads     (16333): Enabling hardware acceleration on an AdView.
D/Ads     (16333): AdLoaderBackgroundTask started.
E/GooglePlayServicesUtil(16333): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
D/Ads     (16333): Fetching ad response from remote ad request service.
E/GooglePlayServicesUtil(16333): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
E/GooglePlayServicesUtil(16333): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
D/Ads     (24313): Binding to the ad request service.
D/Ads     (24313): Starting ad request from service.
D/Ads     (24313): Enabling hardware acceleration on an overlay.
D/Ads     (24313): Getting the ad request URL.
D/Ads     (16333): Received ad response.
D/Ads     (16333): WebView finished loading.
I/Ads     (16333): Scheduling ad refresh 60000 milliseconds from now.
D/Ads     (16333): Pinging Impression URLs.
I/Ads     (16333): Ad finished loading.





William Ferguson

unread,
Jan 27, 2014, 5:21:08 PM1/27/14
to google-adm...@googlegroups.com
Hi Sylvain, can you post the layout xml or code you are using to construct the layout?

William

Sylvain

unread,
Jan 28, 2014, 1:39:01 AM1/28/14
to google-adm...@googlegroups.com
Hello William,

Thanks for your help, so a little more :

1/ First, I use a small "Style / theme" to have a splash_screen at Start.

2/ Then, when the app starts : the AbsoluteLayout + SurfaceView + AdView are created in java.

see 1&2 after, for code source details.

I played a little bit with the layout, and it seems the parent theme : "@android:style/Theme.NoTitleBar.Fullscreen" is the problem.
- If remove the Theme, I have the Title bar, but I have the ads correctly.

Let's forget this custom "style/theme", because the problem can be reduced to :

No theme referenced from Application markup in the AndroidManifest.xml  => TitleBar + Ads OK

If I reference from AndroidManifest.xml (in the Application markup) 
  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
then I have the fullscreen, but the ads does not show !

Of course, I need the NoTitleBar + FullScreen !

Thanks,

Sylvain




about 1/

File "style.xml" :

<resources>
<style name="splashScreenTheme" parent="@android:style/Theme.NoTitleBar.Fullscreen">
    <item name="android:windowBackground">@drawable/splash_shelf</item>
</style>
</resources>


File "AndroidManifest.xml" :
...
    <application android:label="@string/app_name"
                 android:icon="@drawable/ic_launcher"
                 android:theme="@style/splashScreenTheme"

/// or only :   android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

                 >
...
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
        <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

        <activity android:name="MainActivity"
                  android:label="@string/app_name"
                  android:alwaysRetainTaskState="true"
                  android:launchMode="singleInstance"
                  android:screenOrientation="landscape"
                  android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale|uiMode|screenSize|smallestScreenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
  </application>
...


about 2/ :

Nothing special.

        _layout = new AbsoluteLayout(this);
        _layout.addView(_surface_view);

        setContentView(_layout);

then, in a subclass :
         adView = new AdView(this);
         adView.setAdUnitId(".......");
         adView.setAdSize(AdSize.BANNER);

         _layout.addView(adView);

         AdRequest adRequest = new AdRequest.Builder().build();
         adView.loadAd(adRequest);

William Ferguson

unread,
Jan 28, 2014, 4:55:29 PM1/28/14
to google-adm...@googlegroups.com
Sylvain, first thing I'd suggest is to switch form AbsoluteLayout to either LinearLayout or RelativeLayout. AbsoluteLayout was deprecated in API#3 (Cupcake)!

If you use LinearLayoout and give your SurfaceView layout_weight="1" it should expand to fill all he space that the AdView doesn't consume, which is what I think you want.

William


--
 
---
You received this message because you are subscribed to a topic in the Google Groups "Google AdMob Ads Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/avwVXvBt_sM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Sylvain

unread,
Jan 29, 2014, 2:25:19 AM1/29/14
to google-adm...@googlegroups.com
Hello,

I agree, I heard that AbsoluteLayout was deprecated. It will be changed in the future I guess.
Was is strange, is that it works with the 6.4.1, and not with GMS.

Anyway I tried the RelativeLayout.
And this is the Same behavior : the ad does not show-up at first, I need to do a home-restore to make it appeared :

          _layout = new RelativeLayout(this);
          _layout.addView(_surface_view);
          setContentView(_layout);

          RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT);

          params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
          params.addRule(RelativeLayout.ABOVE);
          adView.setLayoutParams(params);

          _layout.addView(adView);

I am not sure LinearLayout is what I want. because the views would be at same z-index.

I would like to have :
- the surface_view needs to be always fullscreen.
- the adview, if it exists (because of Ad retrieved or not, internet connection, and so on) needs to be above (z-index + 1) of the surface_view, and at position x=0, y=0 of the screen.


Thanks,

Sylvain
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.

William Ferguson

unread,
Jan 29, 2014, 2:48:01 AM1/29/14
to google-adm...@googlegroups.com
The child Views of all layouts other than FrameLayout have the same z-order.
So, if you really want to control this using z-order then you have to use a FrameLayout. 

Add the surfaceView first and then the AdView next (on top).



To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.

Sylvain

unread,
Jan 29, 2014, 6:50:39 AM1/29/14
to google-adm...@googlegroups.com
I mean z-index, because one will be over the other (the admob one over the main fullscreen view).
But then can have the same z-index, and one be written after the other ...
It seems relative layout could be fine ...

Two extras investigations :
 
I changed to "FrameLayout",  and same problem : the ads appears 60 sec. or immediatly after home/restore.



I went back to the basics, and I am using now the admob sample code  (... google_play_services/samples/admob).
I did thoses things :

- update project and lib for android-19
- AndroidManifest.xml,     replace to use the theme fullscreen :
      android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
- AndroidManifest.xml,     keep only the activity :  ".BannerCodeActivity" and add the filter Main/Launcher so this is the only one that starts.

- modify the BannerCodeActivity.java to add an empty SurfaceView
         ...
         SurfaceView sv = new SurfaceView(this);
         layout.addView(sv);
         ...
         layout.addView(mAdView, params);
-- update the banner ID in string.xml


And I got the same problem ! ads appears 60s after. or when pressing home/restore.
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsubscrib...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

William Ferguson

unread,
Jan 29, 2014, 8:50:53 AM1/29/14
to google-adm...@googlegroups.com
Sylvain if your intent is to always keep your surfaceView the same size but sometimes overlay the AdView on top of it  then your only choice for a layout is FrameLayout. 

If you use RelativeLayout then your surfaceView will need to shrink in order to provide space for the AdView. Suggest you read up about the different types of layouts and how and when they should be used. 

It sounds like your project structure may be introducing some complexities into the layout. Suggest you build a bare bones (single Activity) app that highlights the issue and post that somewhere.



To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.

Sylvain

unread,
Jan 29, 2014, 10:21:20 AM1/29/14
to google-adm...@googlegroups.com
Exactly, I dont want my main surface to be shrinked. 
I tried the RelativeLayout and the ads was as I wanted (but, If I am correct, not as expected), I mean on top of my surfaceview, but after 60sec.
Maybe this is a little bit different as EGL probably draws itself everywhere it wants.

See my previous post, I have already built the google sample project and I saw the same *bug* ! 
( I just modified it to have fullscreen + a dummy SurfaceView)

I will try to build again the sample project, but with a FrameLayout. I will do it in a couple of days !

Thanks a lot for you help !!
Message has been deleted
Message has been deleted

Sylvain

unread,
Jan 30, 2014, 3:06:39 PM1/30/14
to google-adm...@googlegroups.com
Hi,

I am still having the problem. I use a now a "FrameLayout" and the "admob" sample project. The adview shows up after 60sec (1 cyclic refresh period). Or when I do a home/foreground.

Here is very simple "diff" of my files : "admob/" is my current not-working project, and "admob_backup/" is the original one .

What I did :
- use the fullscreen theme
- add my admob id with a cyclic refresh of 60sec
- use a dummy surface view in the BannerCode, together with the AdView (in the "Banner in Code" sub menu)
- use a FrameLayout (but same problem with all layouts !)

Thanks for you help,

Sylvain

diff -r admob_backup/ admob/ :


21c21
<         android:theme="@style/AppTheme">
---
>         android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
Only in admob: bin
Only in admob: build.xml
Only in admob: gen
Only in admob: libs
Only in admob: local.properties
diff
-r admob_backup/res/layout/activity_banner_code_ad_listener.xml admob/res/layout/activity_banner_code_ad_listener.xml
18c18
< <RelativeLayout
---
> <FrameLayout
23c23
< </RelativeLayout>
---
> </
FrameLayout>
diff
-r admob_backup/res/values/strings.xml admob/res/values/strings.xml
20c20
<     <string name="ad_unit_id">INSERT_YOUR_AD_UNIT_ID_HERE</string>
---
>     <string name="ad_unit_id">My_Id_That_I_Have_Removed
</string>
diff
-r admob_backup/src/com/google/android/gms/samples/ads/BannerCodeActivity.java admob/src/com/google/android/gms/samples/ads/BannerCodeActivity.java
26a27,30
> // Import FrameLayout and SurfaceView+Gravity
> import android.widget.FrameLayout;
> import android.view.*;
>
42,44c46,55
<         RelativeLayout layout = (RelativeLayout) findViewById(R.id.mainLayout);

<         RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
<                 RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
---
>
>         // Create a FrameLayout
>         FrameLayout layout = (FrameLayout) findViewById(R.id.mainLayout);
>         FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
>                 FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.TOP);
>        
>         // Create a Dummy SurfaceView

Eric Leichtenschlag

unread,
Jan 31, 2014, 4:56:34 PM1/31/14
to google-adm...@googlegroups.com
Weird. I'm actually able to reproduce this, but only if the ad is on top of the surface view, not if the surface view is layed out below the AdView. I'm not sure why that would be the case, but is there a reason you want them to overlay? In that case, the ad would cover your content.

Thanks,
Eric

Sylvain

unread,
Feb 1, 2014, 4:39:28 AM2/1/14
to google-adm...@googlegroups.com
Hi,

Thanks for reproducing the problem !

I would say *Yes and No* to your remark: the ad covers the SurfaceView. But the content of the  SurfaceView is actually expecting an Ads of 50 DIP. So, the content, is shifted of 50 DIP (in fact more that 50 DIP).
The ads will only overlay the background image.

For me, it has a few advantages :
- The banner is not 100% wide. so I still have my game on the right of the banner. (I dont want to switch to Smart Banner right now, as the height is to big for me).
- It allows me to never handle any resize events send to the SurfaceView, which are awkward and slow to handle in native application.

More details :
- my java part consists of this SurfaceView. But the whole application is native and using opengl.

In 6.4.1, it was working correctly ! Maybe the integration within google-play-services introduce a new behaviour, or could it be a corner case ?

Thanks,

Sylvain

David Lott

unread,
Feb 3, 2014, 10:52:20 PM2/3/14
to google-adm...@googlegroups.com
I was having this trouble as well and found a work-around.

First thing is don't add the ad to your layout initially!  I created an AdListener() and set it to my ad view.  Then in onAdLoaded, I put the ad view into my layout at that point.  You have to take care to only add the ad view once, and not every time an ad is loaded of course!  But this seems to make sure the ad is displayed the first time it is loaded, and not skipped.

Here is an example:

adView.setAdListener(new AdListener()
   {
    @Override
    public void onAdLoaded()
    {
    if(firstTime)
    {
    firstTime = false;
    layout.addView(adView);
    }
    }
   });

Sylvain

unread,
Feb 4, 2014, 1:44:46 PM2/4/14
to google-adm...@googlegroups.com
Thanks David, your workaround solves my problem for now !

@Eric, I hope will get a fix in a future release !


Also, other things I noticed :
- Admob+Google-play-services is adding an overhead of 0.6 MB compared to only Admob. Which is quite big for small apps ...
- I notice three message in the logcat :
"The Google Play services resources were not found. Check your project configuration to ensure that the resources are included."
Even if the ressource are included.
- the addTestDevice only works if I turned my device in english !

And anoher one, strang :
1- start a portrait application with Admob+Google-play-services
2- click the (test) ad ... then press back to get back to the application
3- now press home, then restore the application : I see a little "hiccup" : the app goes up and down for 0.5 seconds.
If I dont do 2/, then the hiccup does not appear.

Thanks.















Eric Leichtenschlag

unread,
Feb 4, 2014, 6:50:29 PM2/4/14
to google-adm...@googlegroups.com
HI Sylvian,

In addition to David's solution, I was also able to get this to work by simply setting a background color on the AdView:

adView.setBackgroundColor(Color.TRANSPARENT);

I tried turning off hardware acceleration and invalidating the AdView to make it draw, but none of that worked. I'm not sure what the SDK can do to fix this (other than the line above) but that still don't help us understand the core of the problem.

As far as your other questions:

1. I haven't tested to see what the size is on Google Play services, but if you use proguard, you should be able to strip out and obfuscate classes I would expect the end result to be comparable.
2. The Google Play resources logging issues is a a benign logging message that can be ignored.
3. We do need to update our test ads to support other languages. Thanks.
4. That sounds weird, but I wasn't able to reproduce the hiccup behavior.

Thanks,
Eric

Sylvain

unread,
Feb 5, 2014, 1:06:23 PM2/5/14
to google-adm...@googlegroups.com
Hi Eric,

Your workaround works also on my side !
I don't know the problem. Obviously you have and also know more information than me on the subject :)
All I know, is that it was working with admob 6.4.1.
So, I would be cut the problem in two :
.. is the asynchronous (?) google-play-services mecanism adding the problem ? (maybe you have the possibility to run the latest version of admob as its own a .jar)
.. or something is added/removed in the admob module ? And then go for running with revisions from 6.4.1 to latest !

thanks also for the answers to 1/2/3/4 !

... about the *hiccup* :)
I could reproduce it with the "admob sample" application. With the same "diff" as previous and also :
- use addTestDevice
- replace the FrameLayout by a RelativeLayout in the .java and the .xml
- no need for "LayoutParams"
- use also you workaround "mAdView.setBackgroundColor(Color.TRANSPARENT);".

Use the same procedure :
1- start a portrait application with Admob+Google-play-services
2- click the (test) ad ... then press back to get back to the application
3- now press home, then restore the application : I see a little "hiccup" : the app goes up and down for 0.5 seconds.
If I dont do 2/, then the hiccup does not appear.


And ... curiously :
Without the workaround "mAdView.setBackgroundColor(Color.TRANSPARENT);".
The hiccup is always present ! I mean without the need to click the test-ad.

It looks very weird, maybe both problem are related !


Thanks,
Sylvain

Eric Leichtenschlag

unread,
Feb 6, 2014, 8:45:57 PM2/6/14
to google-adm...@googlegroups.com
Hi Sylvain,

I'm still not able to reproduce the hiccup. Perhaps I'm not understanding what it's supposed to look like. Could you provide a short video that shows the behavior?

Thanks,
Eric

Sylvain

unread,
Feb 7, 2014, 3:20:44 AM2/7/14
to google-adm...@googlegroups.com
Hi Eric,

Sorry. It could not reproduce it, neither with Nexus7 (4.4), nor Nexus10 (4.4). I did not try with the Nexus5.
But I am seeing it with a recent HTC ONE (android 4.3).

You'll receive magically the video of the hiccup !

I do 4 "restore/home" : 
first one : nothing happen because I did not click the test-ad
I click the test-ad
second : the hiccup appears.
third : no hiccup :/
forth : the hiccup appears.


... then you'll see, this is a picky bug ... but I am just reporting. It may hide another bug !
And since, that are lots of users, you want want to fix!
Moreover, It may be related to the first one : If don't put the "Color.Transparent workaround", the hiccup occurs without the need to click the Ad !

Thanks,

Sylvain

aashish dalal

unread,
Feb 23, 2014, 5:37:44 AM2/23/14
to google-adm...@googlegroups.com
Hi Sylvain,

                I just started working on android application and observed a similar behaviour. I have a small game application developed using libgdx. I am adding admob to it. The behaviour I observed is, my Ads are loading but they are not visible on the relative layout but they are present as I can click on them because I know where they should be present. Once I click on them, they direct me to the Ad page and when I do ->back to Application, the ads are visible then onward. Can someone please suggest a proper solution to this or this is not fixed yet

.I was able to make it work by using Eric's method of making background Transparent.Thanks a lot Eric.

Thanks & Regards,
Aashish

Tomáš Rychnovský

unread,
Mar 15, 2014, 11:24:23 AM3/15/14
to google-adm...@googlegroups.com
Hi Eric,

 I have exactly the same issue as Sylvian has. Setting transparent color helped me too but there is probably something rotten with GLSurfaceView...

 Beside AdMob I am using also LiquidM (former Madvertise) and Amazon ads. I am encountering these issues:

 AdMob:
 - old SDK worked OK,
 - with new SDK first ad was invisible, but still it was possible to click it. After return from browser or when pressing home and returning back the ad became visible. Here works you workaroung with transparent color,
 - (beside this I think that in old SDK ads were refreshed in the same way as real ads. With new Google Play SDK I do not get ads refresh when testing is on - only when I get real ads with testing off)

 LiquidM:
 - I was getting very strange behaviour. When the ad is loaded, it is first displayed in the bottom and immediately after it on its right place. See screenshot: https://sites.google.com/site/sbcgamesdev/blogfiles/Screenshot_2014-03-15-14-33-12.jpg,
 - again. When clicked and returned from browser or when home pressed and returned to game, the bottom banner disappears and everything is OK,
 - I found workaround - I have to set view to View.LAYER_TYPE_SOFTWARE and then it works all OK

 Amazon:
 - when I set View.LAYER_TYPE_SOFTWARE then ad is in most of the times displayed correctly but sometimes there is problem similar to AdMob. setting transparent color does not help. The ad is again in place but invisible - you can click it. Again, when returning from browser or when pressing home the ad gets visible. Here is screenshot how it look, when everything is OK: https://sites.google.com/site/sbcgamesdev/blogfiles/Screenshot_2014-03-15-15-50-49.jpg
 - when I do not set View.LAYER_TYPE_SOFTWARE then ad is visible every time but with ugly white borders on its sides: https://sites.google.com/site/sbcgamesdev/blogfiles/Screenshot_2014-03-15-15-51-56.jpg

  My test device is Samsung Galaxy Tab 10.1 with Android 4.0.4 installed.

Regards,
Tomas

Eric Leichtenschlag

unread,
Mar 17, 2014, 10:54:09 PM3/17/14
to google-adm...@googlegroups.com
Hi Tomas,

Hardware acceleration has been a pain on Android. The AdMob WebView turns it off, at least for older versions that don't support it well, which is why you don't have to set the layer type with AdMob.

The lack of refresh on AdMob may just be our test ad unit not having a refresh rate on it. It shouldn't have anything to do with your code. The first ad being invisible is really weird, I've seen it too when using Unity which is probably using some SurfaceView as well. I'd recommend using the transparent color workaround.

I believe the Amazon issue has something to with how they're inflating their view post click in their SDK. 

Thanks,
Eric
Message has been deleted

shaunliz

unread,
Mar 21, 2014, 4:36:41 AM3/21/14
to google-adm...@googlegroups.com

Thanks David ~ 
It was very useful for me.

2014년 2월 4일 화요일 오후 12시 52분 20초 UTC+9, David Lott 님의 말:

rajesh yapalaparvi

unread,
Apr 18, 2014, 8:39:12 AM4/18/14
to google-adm...@googlegroups.com
Hi
I have problem in ad banner , in the 1st install ads are displayed but when i quit the game and relaunch it the ads are not getting display  can any one help in this(WP8).

Jean-Claude Cottier

unread,
Apr 22, 2014, 9:27:07 AM4/22/14
to google-adm...@googlegroups.com
The transparent color tips isn't working all the time. If you hide the ads (at least before it is loaded) then unhide later, it is not working. Instead of simply making the view visible or invisible (adView.setVisibility(View.INVISIBLE);). I had to remove/add the view instead. I'm still using the transparent color trick for the first time it is starting.

Eric Leichtenschlag

unread,
Apr 23, 2014, 4:42:27 PM4/23/14
to google-adm...@googlegroups.com
Hi Jean,

Do you have a minimal sample that reproduces the behavior of the transparent color not working?

Thanks,
Eric

Jean-Claude Cottier

unread,
Apr 23, 2014, 5:05:44 PM4/23/14
to google-adm...@googlegroups.com
Hi Eric,

Basically, I was hiding the ad view using adView.setVisibility(View.INVISIBLE) before the ad was loaded.
Then later, after it was loaded, I was making it visible: adView.setVisibility(View.VISIBLE) and it never appears back (despite setting the invisible background).
I've solved my problem by not using INVISIBLE/VISIBLE but by removing/adding the view in my layout.
The tip with the background was working but only if I didn't hide the view.

FYI: when the first banner is not visible, if you minimize the app and come back, the ads will become visible.

Hope it helps.

thanks

JC

--

---
You received this message because you are subscribed to a topic in the Google Groups "Google AdMob Ads Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/avwVXvBt_sM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eric Leichtenschlag

unread,
Apr 23, 2014, 5:21:53 PM4/23/14
to google-adm...@googlegroups.com
I wasn't able to reproduce with the following code, so I'm thinking it may only happen under certain conditions. Are you using a SurfaceView or some form of OpenGL?

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Create an ad.
    adView = new AdView(this);
    adView.setAdSize(AdSize.BANNER);
    adView.setAdUnitId(AD_UNIT_ID);
    adView.setAdListener(new AdListener() {
      @Override
      public void onAdLoaded() {
        adView.setVisibility(View.VISIBLE);
      }
    });

    RelativeLayout layout = (RelativeLayout) findViewById(R.id.linearLayout);
    layout.addView(adView, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    AdRequest adRequest = new AdRequest.Builder()
        .addTestDevice("0198B6D718A8511DFC03A556552F4C8E")
        .build();
    adView.loadAd(adRequest);
    
    adView.setVisibility(View.INVISIBLE);
  }

Thanks,
Eric


On Wednesday, April 23, 2014 2:05:44 PM UTC-7, Jean-Claude Cottier wrote:
Hi Eric,

Basically, I was hiding the ad view using adView.setVisibility(View.INVISIBLE) before the ad was loaded.
Then later, after it was loaded, I was making it visible: adView.setVisibility(View.VISIBLE) and it never appears back (despite setting the invisible background).
I've solved my problem by not using INVISIBLE/VISIBLE but by removing/adding the view in my layout.
The tip with the background was working but only if I didn't hide the view.

FYI: when the first banner is not visible, if you minimize the app and come back, the ads will become visible.

Hope it helps.

thanks

JC

To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.

Jean-Claude Cottier

unread,
Apr 23, 2014, 5:24:56 PM4/23/14
to google-adm...@googlegroups.com
yes, I'm using surfaceview with opengl.

JC


To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.

Eric Leichtenschlag

unread,
Apr 23, 2014, 5:53:10 PM4/23/14
to google-adm...@googlegroups.com
So I've been playing around with this. When I use the code mentioned above with a SurfaceView, the first ad does not show for me when I turned the ad visible, but the next refresh made it visible. I was also only able to reproduce this if the AdView is stacked on top of the SurfaceView. If I lay out the Surface View below the AdView, the ad shows even if I don't set the background. Can you try doing that?

Thanks,
Eric

On Wednesday, April 23, 2014 2:24:56 PM UTC-7, Jean-Claude Cottier wrote:
yes, I'm using surfaceview with opengl.

JC
Hi Eric,
JC

To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsubscrib...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Jean-Claude Cottier

unread,
Apr 23, 2014, 5:56:01 PM4/23/14
to google-adm...@googlegroups.com
ok, I'll try this tomorow it's late in France... I'm not very good in Java (my engine is mainly c++) can you give me the code to layout the surfaceview under the ad view please?

thanks

JC


To unsubscribe from this group and all its topics, send an email to google-admob-ads...@googlegroups.com.

Eric Leichtenschlag

unread,
Apr 23, 2014, 6:05:21 PM4/23/14
to google-adm...@googlegroups.com
public class MainActivity extends Activity {
  private AdView adView;
  private GLSurfaceView glSurfaceView;
  private static final int AD_ID = 0x12345;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    RelativeLayout layout = new RelativeLayout(this);

    // Create full screen Surface View.
    glSurfaceView = new GLSurfaceView(this);
    glSurfaceView.setRenderer(...);
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                                        LayoutParams.MATCH_PARENT);
    params.addRule(RelativeLayout.BELOW, AD_ID);
    

    // Create the AdView.
    adView = new AdView(this);
    adView.setId(AD_ID);
    adView.setAdUnitId("MY_AD_UNIT_ID");
    adView.setAdSize(AdSize.BANNER);
    adView.setAdListener(new AdListener() {
      @Override
      public void onAdLoaded() {
        adView.setVisibility(View.VISIBLE);
      }
    });
    RelativeLayout.LayoutParams adParams =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                                        LayoutParams.WRAP_CONTENT);
    adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);

    adView.loadAd(new AdRequest.Builder().build());

    layout.addView(adView, adParams);
    layout.addView(glSurfaceView, params);

    setContentView(layout);
    adView.setVisibility(View.INVISIBLE);
  }

  @Override
  protected void onResume() {
    super.onResume();
    adView.resume();
    glSurfaceView.onResume();
  }

  @Override
  protected void onPause() {
    adView.pause();
    glSurfaceView.onPause();
    super.onPause();
  }
}



On Wednesday, April 23, 2014 2:56:01 PM UTC-7, Jean-Claude Cottier wrote:
ok, I'll try this tomorow it's late in France... I'm not very good in Java (my engine is mainly c++) can you give me the code to layout the surfaceview under the ad view please?

thanks

JC

Daniele De Sanctis

unread,
May 28, 2014, 11:08:32 AM5/28/14
to google-adm...@googlegroups.com
This work very good for me:

 adView.setAdListener(new AdListener() {
      @Override
      public void onAdLoaded() {
        adView.setVisibility(View.VISIBLE);
      }
    });

Adding that snippet the Ad is showed also by the first time.

Thanks!
Reply all
Reply to author
Forward
0 new messages