Background
Over the past 2 weeks, I have moved my application from ActionBarSherlock to the official Google Support Library to also get the Material-Design style.
I upgraded to the latest (it's 21), and I included both v4 and v7 in it.
My application has a simple navigation box, an action bar and a fragments container for switching between fragments (which I only 2). The remaining screens are the settings screen and shortcuts for OS tools. I also have a widget configuration screen, but that doesn't matter.
Problem
I got a crash from a user who claims to crash every time on the LG-G2 with Android 4.4:
java.lang.ClassCastException: android.support.v7.internal.widget.m cannot be cast to com.android.internal.widget.ActionBarOverlayLayout$LayoutParams at com.android.internal.widget.ActionBarOverlayLayout.applyInsets(ActionBarOverlayLayout.java:172) at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:317) at android.view.View.measure(View.java:16538) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5140) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2374) at android.view.View.measure(View.java:16538) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1964) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1160) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1342) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1047) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5896) 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:5105) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132) at dalvik.system.NativeStart.main(Native Method)
In XML, I use
Here is the short version of XML that I use for the layout:
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:id="@+id/activity_app_list__drawerLayout" android:layout_width="match_parent" android:layout_height="match_parent" > <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" > <FrameLayout android:id="@+id/activity_app_list__fragmentContainer" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/activity_app_list__adContainer" android:layout_alignParentTop="true" /> <FrameLayout android:id="@+id/activity_app_list__adContainer" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" /> </RelativeLayout> <ScrollView android:id="@+id/activity_app_list__drawerView" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" android:background="?android:attr/windowBackground" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <==just some views for the drawer... </LinearLayout> </ScrollView> </android.support.v4.widget.DrawerLayout>
What i found
I searched the Internet and found almost nothing about this problem.
The only thing I found is this post , but they donโt say how and why this happens. Plus, I donโt even use this library, and I'm not sure if it is the same error. The tip was to remove the following code:
(ViewGroup)findViewById(android.R.id.content).setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
Question
Why is this happening? How can i fix this?
Will use a tooltip in the message?