Not enough space to show ad with ViewPager

410 views
Skip to first unread message

FiltrSoft

unread,
Feb 26, 2013, 5:27:13 PM2/26/13
to google-adm...@googlegroups.com
Has anyone successfully integrated AdMob into an Android app with a ViewPager?  I'm getting an issue where they are not showing or they show, but sporadically.  I think it has something to do with how ViewPagers cache the views, but I'm not entirely sure.

I have a SO post that details it more:

http://stackoverflow.com/questions/15056404/not-enough-space-to-show-ad-with-viewpager

Eric Leichtenschlag

unread,
Feb 26, 2013, 6:09:59 PM2/26/13
to google-adm...@googlegroups.com
Hey FiltrSoft,

We have an example on including ads within a Tabbed View in our Ad Catalog project. It doesn't use a VIewPager, but was based off of the Android ViewPager example. This example puts the ad outside of the TabHost (as you can see from the XML file) so you don't have to worry about changing the ad state when the tab changes.

Thanks,
Eric



--
 
---
You received this message because you are subscribed to the Google Groups "Google AdMob Ads Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
  

Eric Leichtenschlag

unread,
Feb 26, 2013, 6:13:15 PM2/26/13
to google-adm...@googlegroups.com
From your SO post, it looks like you're actually using a ListView. The Ad Catalog has an example for that too, which includes a List Adapter wrapper that adds an ad at the top and bottom of your ListView.

Thanks,
Eric

FiltrSoft

unread,
Feb 26, 2013, 8:27:16 PM2/26/13
to google-adm...@googlegroups.com
Eric, thanks for the response. Setting the ad via XML, as opposed to programmatically, seemed to get the ads working.

One other thing, have you seen this issue before?  If there is an ad showing on one of the pages of the ViewPager and I swipe on the ad itself, my app is crashing with a NullPointerException coming from the ad itself.  Something to do with "canScrollHorizontally"?  A Google search of "canScrollHorizontally" didn't seem to return many results.

02-26 20:22:53.865: E/AndroidRuntime(9554): java.lang.NullPointerException
02-26 20:22:53.865: E/AndroidRuntime(9554):     at com.google.ads.util.h.a(SourceFile:52)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at com.google.ads.internal.AdWebView.canScrollHorizontally(SourceFile:398)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.support.v4.view.ViewCompatICS.canScrollHorizontally(ViewCompatICS.java:30)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.support.v4.view.ViewCompat$ICSViewCompatImpl.canScrollHorizontally(ViewCompat.java:237)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.support.v4.view.ViewCompat.canScrollHorizontally(ViewCompat.java:347)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.support.v4.view.ViewPager.canScroll(ViewPager.java:2377)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.support.v4.view.ViewPager.canScroll(ViewPager.java:2368)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.support.v4.view.ViewPager.canScroll(ViewPager.java:2368)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.support.v4.view.ViewPager.canScroll(ViewPager.java:2368)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.support.v4.view.ViewPager.canScroll(ViewPager.java:2368)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.support.v4.view.ViewPager.canScroll(ViewPager.java:2368)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.support.v4.view.ViewPager.canScroll(ViewPager.java:2368)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.support.v4.view.ViewPager.onInterceptTouchEvent(ViewPager.java:1775)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1817)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1953)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1405)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.app.Activity.dispatchTouchEvent(Activity.java:2410)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1901)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.View.dispatchPointerEvent(View.java:7426)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3220)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3165)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4292)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4271)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4363)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:179)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:171)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:4342)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:4382)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.Choreographer.doCallbacks(Choreographer.java:562)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.Choreographer.doFrame(Choreographer.java:530)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.os.Handler.handleCallback(Handler.java:725)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.os.Handler.dispatchMessage(Handler.java:92)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.os.Looper.loop(Looper.java:137)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at android.app.ActivityThread.main(ActivityThread.java:5041)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at java.lang.reflect.Method.invokeNative(Native Method)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at java.lang.reflect.Method.invoke(Method.java:511)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-26 20:22:53.865: E/AndroidRuntime(9554):     at dalvik.system.NativeStart.main(Native Method)
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.

FiltrSoft

unread,
Feb 28, 2013, 10:05:52 AM2/28/13
to google-adm...@googlegroups.com
I ended up reverting to the older AdMob JAR, which didn't seem to have this issue.

Eric Leichtenschlag

unread,
Feb 28, 2013, 12:08:36 PM2/28/13
to google-adm...@googlegroups.com
It looks like this crash was introduced with v6.3.0. v6.2.1 shouldn't have the issue, and it'll be fixed for the next release.

Thanks,
Eric


To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages