After changing the Height of HorizontalScrollView from
<HorizontalScrollView
android:id="@+id/topics_scroll_view"
android:layout_width="match_parent"
android:layout_height="92dp"/>
to
<HorizontalScrollView
android:id="@+id/topics_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
i started getting this crash
Caused by java.lang.ClassCastException
android.view.AbsSavedState$1 cannot be cast to android.widget.HorizontalScrollView$SavedState
android.widget.HorizontalScrollView.onRestoreInstanceState (HorizontalScrollView.java:1678)
the crash is happening on this method in HorizontalScrollView
@Override
protected void onRestoreInstanceState(Parcelable state) {
if (mContext.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.JELLY_BEAN_MR2) {
// Some old apps reused IDs in ways they shouldn't have.
// Don't break them, but they don't get scroll state restoration.
super.onRestoreInstanceState(state);
return;
}
SavedState ss = (SavedState) state; //*******this line is crashing
super.onRestoreInstanceState(ss.getSuperState());
mSavedState = ss;
requestLayout();
}
i found a similar issue and i suspected that obfuscation is not keeping Parcelable and they suggested to add this to proguard file
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}
when i looked at my proguard file i found that i have already included the below
-keepnames class * implements android.os.Parcelable { *; }
-keepclassmembers class * implements android.os.Parcelable { *; }
can anyone distinguish the problem and why it started crashing now when i changed the android:layout_height
?
does this make sense to anyone?
thanks in advance
EDIT: after reading some similar problems i found this one java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.support.v7.widget.Toolbar$SavedState
now if you read the answer its saying that using same android:id
for different view can cause this so it got my attention that i recently added a view that is included in the same layout with the HorizontalScrollView and that views hold this
<RelativeLayout
android:id="@+id/topics_scroll_view"
android:layout_width="match_parent"
android:layout_height="92dp"/>
Can this be the problem?