ClassCastException

601 views
Skip to first unread message

Giuseppe Iuculano

unread,
Aug 28, 2014, 10:07:19 AM8/28/14
to google-adm...@googlegroups.com
Hi,

I've a crash that seems to be related to AdMob sdk (Google Play Services version)

This is the crashlytics issue: http://crashes.to/s/ffc635286c5

java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.FrameLayout$LayoutParams
       at android
.widget.FrameLayout.onMeasure(FrameLayout.java:311)
       at android
.view.View.measure(View.java:16497)
       at android
.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
       at android
.widget.FrameLayout.onMeasure(FrameLayout.java:310)
       at android
.view.View.measure(View.java:16497)
       at android
.view.ViewGroup.measureChild(ViewGroup.java:5096)
       at com
.google.android.gms.ads.AdView.onMeasure()
       at android
.view.View.measure(View.java:16497)
       at android
.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
       at android
.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
       at android
.widget.LinearLayout.measureVertical(LinearLayout.java:695)
       at android
.widget.LinearLayout.onMeasure(LinearLayout.java:588)
       at android
.view.View.measure(View.java:16497)
       at android
.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
       at android
.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
       at android
.view.View.measure(View.java:16497)
       at android
.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
       at android
.widget.FrameLayout.onMeasure(FrameLayout.java:310)
       at android
.view.View.measure(View.java:16497)
       at android
.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
       at android
.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
       at android
.widget.LinearLayout.measureVertical(LinearLayout.java:695)
       at android
.widget.LinearLayout.onMeasure(LinearLayout.java:588)
       at android
.view.View.measure(View.java:16497)
       at android
.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
       at android
.widget.FrameLayout.onMeasure(FrameLayout.java:310)
       at com
.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
       at android
.view.View.measure(View.java:16497)
       at android
.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1912)
       at android
.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1109)
       at android
.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1291)
       at android
.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
       at android
.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600)
       at android
.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
       at android
.view.Choreographer.doCallbacks(Choreographer.java:574)
       at android
.view.Choreographer.doFrame(Choreographer.java:544)
       at android
.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
       at android
.os.Handler.handleCallback(Handler.java:733)
       at android
.os.Handler.dispatchMessage(Handler.java:95)
       at android
.os.Looper.loop(Looper.java:136)
       at android
.app.ActivityThread.main(ActivityThread.java:5001)
       at java
.lang.reflect.Method.invokeNative(Method.java)
       at java
.lang.reflect.Method.invoke(Method.java:515)
       at com
.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
       at com
.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
       at dalvik
.system.NativeStart.main(NativeStart.java)


Cheers,
Giuseppe

Eric Leichtenschlag

unread,
Aug 28, 2014, 3:15:19 PM8/28/14
to google-adm...@googlegroups.com
Agreed that the com.google.android.gms.ads.AdView.onMeasure() line does look fishy. I have filed a bug for this, and will keep you posted.

Thanks,
Eric

       at android
.<span style="co
...

Eric Leichtenschlag

unread,
Aug 28, 2014, 3:20:32 PM8/28/14
to google-adm...@googlegroups.com
Did the crash happen out of nowhere, or did you recently update your app?

Giuseppe Iuculano

unread,
Aug 28, 2014, 3:36:00 PM8/28/14
to google-adm...@googlegroups.com
Hi Eric,

I recently updated my app. The only relevant thing that I added is the Facebook mediation network.

Cheers,
Giuseppe.

Eric Leichtenschlag

unread,
Aug 28, 2014, 3:43:52 PM8/28/14
to google-adm...@googlegroups.com
Did you change the google play services client version too?

Also, I'm not sure if it's related yet or not, but does your AdView happen to be in a RelativeLayout and/or be added with RelativeLayout.LayoutParams?

Giuseppe Iuculano

unread,
Aug 28, 2014, 4:06:03 PM8/28/14
to google-adm...@googlegroups.com
I've the last Google Play services lib. When I update the app I make sure that I've the latest Google Play services lib, and if this can help you the previous version was uploaded on June 21.

I've two activity with an AdView. In the first one I add it from java in a linearlayout:

llayout.addView(adView);



In the second one I added it in the xml:

<RelativeLayout xmlns:ads="http://schemas.android.com/apk/res-auto"
   
xmlns:android="http://schemas.android.com/apk/res/android"
   
xmlns:marquee="http://schemas.android.com/apk/res-auto"
   
xmlns:tools="http://schemas.android.com/tools"
   
android:id="@+id/relativelayout"
   
android:layout_width="match_parent"
   
android:layout_height="match_parent" >


   
<LinearLayout
       
android:id="@+id/adViewlinear"
       
android:layout_width="320dp"
       
android:layout_height="50dp"
       
android:layout_centerHorizontal="true"
       
android:orientation="vertical" >


       
<com.google.android.gms.ads.AdView
           
android:id="@+id/adView"
           
android:layout_width="wrap_content"
           
android:layout_height="wrap_content"
           
ads:adSize="BANNER"
           
ads:adUnitId="XXXXXXXXXXX" />
   
</LinearLayout>


[...]





Eric Leichtenschlag

unread,
Aug 29, 2014, 3:30:38 PM8/29/14
to google-adm...@googlegroups.com
Thanks. This crash is still under investigation. We've been able to reproduce this when using the Facebook adapter and then closing the app. Are you doing anything ads-related when the app is closed other than calling adView.pause() or adView.destroy()?

The SDK team thinks it's an issue with the Facebook adapter, or at least the Facebook adapter is exposing an issue in the SDK. Could you try turning off requests to Facebook for a day and see if the crashes subside?

Thanks,
Eric
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Giuseppe Iuculano

unread,
Sep 2, 2014, 3:07:00 AM9/2/14
to google-adm...@googlegroups.com
When calling adView.pause() or adView.destroy() I didn't do anything  ads-related.
I paused Facebook ads about at 11 CEST, and I've not received any crash anymore, we will see tomorrow if the crashes subside

Cheers,
Giuseppe

Giuseppe Iuculano

unread,
Sep 2, 2014, 5:09:11 AM9/2/14
to google-adm...@googlegroups.com
Hi Eric,

after a day that I stopped Facebook ads I confirm that seems to be related to Facebook adapter, the last crash is from yesterday.

Cheers,
Giuseppe

Eric Leichtenschlag

unread,
Sep 3, 2014, 3:05:46 PM9/3/14
to google-adm...@googlegroups.com
Thanks for confirming. As a short term solution, we'll work on updating the Facebook adapter with a fix, while we're investigating if a fix needs to go into the mobile ads SDK as well. I'll update this thread when a new Facebook adapter is available.

Thanks,
Eric

Giuseppe Iuculano

unread,
Sep 17, 2014, 3:03:32 AM9/17/14
to google-adm...@googlegroups.com
Hi Eric,

any news on this?

Cheers,
Giuseppe

Eric Leichtenschlag

unread,
Sep 18, 2014, 9:50:01 PM9/18/14
to google-adm...@googlegroups.com
Unfortunately not yet. I'll escalate again.

Thanks,
Eric

Eric Leichtenschlag

unread,
Sep 19, 2014, 4:09:33 PM9/19/14
to google-adm...@googlegroups.com
SDK team is still looking into this, but it isn't clear what the right fix is. The adapter wraps Facebook's AdView (which is a RelativeLayout) in a FrameLayout, but it's unclear how the adapter could be pulling the wrong layout parameter types.

Alessandro G.

unread,
Sep 27, 2014, 8:07:12 AM9/27/14
to google-adm...@googlegroups.com
We are experiencing the same issue. We tried to create our own Facebook Adapter but we ended up receiving the same error. Wrapping the Facebook AdView into a FrameLayout or setting its layout properties as FrameLayout.LayoutParams doesn't seem to help.


Any news about a fix?

Thanks, 
Alessandro

Eric Leichtenschlag

unread,
Sep 29, 2014, 2:26:45 PM9/29/14
to google-adm...@googlegroups.com
Unfortunately still no news yet. I've just asked for another update.

Are you able to consistently reproduce the crash?

Max

unread,
Oct 1, 2014, 8:10:51 PM10/1/14
to google-adm...@googlegroups.com
We have been having very similar issue... It looks like the issue started once we were forced to ditch the standalone AdMob SDK and to switch to the Google Play Services.

Her's the stack trace. We would appreciate if this can be fixed asap. The app seems to crash (in our case) on orientation change (maybe other cases as well too, this is what we managed to find)  BUT crashes are very inconsistent. Most time it works and does not crash. The amount of crashes is still quite large and we can't roll out new features since we are stuck with limited roll out due to large number of crashes that we don't want to roll to all of our users.


java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams
       at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1010)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:590)
       at android.view.View.measure(View.java:16537)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5135)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
       at android.view.View.measure(View.java:16537)
       at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
       at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
       at android.view.View.measure(View.java:16537)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5135)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
       at android.view.View.measure(View.java:16537)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5135)
       at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:327)
       at android.view.View.measure(View.java:16537)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5135)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
       at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
       at android.view.View.measure(View.java:16537)
       at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1947)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1713)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1024)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5796)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
       at android.view.Choreographer.doCallbacks(Choreographer.java:574)
       at android.view.Choreographer.doFrame(Choreographer.java:544)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
       at android.os.Handler.handleCallback(Handler.java:733)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5102)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
       at dalvik.system.NativeStart.main(NativeStart.java)


There is no mention of any SDK specific code so we thought it must come from Google Play ads (especially since we found very similar issue here). We might be wrong of course in which case we'd appreciate a pointer in the direction we should be looking at.

Eric Leichtenschlag

unread,
Oct 2, 2014, 2:31:07 PM10/2/14
to google-adm...@googlegroups.com
Are you using the Facebook adapter? In other reported cases, we've isolated the issue to that adapter. But we haven't been able to reproduce consistently or figure out a fix for it yet.

       at android
.os.Handler.handleCallback(Handler.java:</span
...

Giuseppe Iuculano

unread,
Oct 2, 2014, 3:52:36 PM10/2/14
to google-adm...@googlegroups.com
Eric, you can reproduce the issue with an activity that forces landscape mode and press the back button when you are in portrait.

Cheers,
Giuseppe

Eric Leichtenschlag

unread,
Oct 3, 2014, 11:41:39 AM10/3/14
to google-adm...@googlegroups.com
Thanks Guiseppe. I've forwarded that information along.
</blockquo
...

Alessandro Lacroce

unread,
Oct 13, 2014, 10:53:48 AM10/13/14
to google-adm...@googlegroups.com
We are using Unity plugin and the official Facebook Adapter. You can test it in an empty scene with a Facebook banner (320x50) and rotate the android phone from portrait to landscape. 

Eric Leichtenschlag

unread,
Oct 13, 2014, 2:57:53 PM10/13/14
to google-adm...@googlegroups.com
Still waiting on a fix, but I hope to have a more informational update soon.

Thanks,
Eric

Jenny Abrahamson

unread,
Oct 13, 2014, 3:28:49 PM10/13/14
to google-adm...@googlegroups.com
Hi guys, what version of the Facebook SDK are you using? We fixed an issue that looks like this in v3.18.1 (https://developers.facebook.com/bugs/1523899821174664/)

Alessandro Lacroce

unread,
Oct 14, 2014, 5:16:36 AM10/14/14
to google-adm...@googlegroups.com
Thanks for the reply, 

I can confirm that using the version 3.19.0 fixes the problem :)
Reply all
Reply to author
Forward
0 new messages