-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
Problem:
When my Robolectric test executes the following line it crashes (it doesn't crash on the actual device).
Note: I have gotten rid of any usages of LinearLayout as suggested here: https://stackoverflow.com/a/11493550/1859486
StickyListHeadersListView.setAdapter(adapter);
My setup
Plugins:
classpath 'com.android.tools.build:gradle:3.2.1'
Dependences:
implementation 'se.emilsjolander:stickylistheaders:2.7.0@aar'
Test dependencies:
testImplementation('org.robolectric:robolectric:4.1') {
exclude group: 'org.bouncycastle', module: 'bcprov-jdk15on'
exclude group: 'androidx.test', module: 'monitor'
}
Stacktrace:
java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
at android.widget.ListView.clearRecycledState(ListView.java:532)
at android.widget.ListView.resetList(ListView.java:519)
at android.widget.ListView.setAdapter(ListView.java:462)
at se.emilsjolander.stickylistheaders.StickyListHeadersListView.setAdapter(StickyListHeadersListView.java:722)
Update
I've traced the root cause and isolated it to this line:
listView.addFooterView(inflater.inflate(R.layout.list_footer, container, false));
Interestingly enough, it only causes failures when running @config(sdk = Build.VERSION_CODES.KITKAT) or @config(sdk = Build.VERSION_CODES.O). It works fine on @config(sdk = Build.VERSION_CODES.P)
list_footer.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
>
<Space
android:layout_width="match_parent"
android:layout_height="@dimen/activity_vertical_margin_large"
/>
</LinearLayout>
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels