How to fix ‘Design assumption violated’ error in ViewPager2?


I’m using ViewPager2, Kotlin and AndroidX. When the adapter is not at index 0 and I change the adapter list and set current item to index 0 the exception is thrown.

java.lang.IllegalStateException: Design assumption violated.
        at androidx.viewpager2.widget.ViewPager2.updateCurrentItem(
        at androidx.viewpager2.widget.ViewPager2$4.onAnimationsFinished(
        at androidx.recyclerview.widget.RecyclerView$ItemAnimator.isRunning(
        at androidx.viewpager2.widget.ViewPager2.onLayout(
        at android.view.View.layout(

In line 537 of ViewPager2 there is an if which causes the exception:

        // Extra checks verifying assumptions
        // TODO: remove after testing
        View snapView1  mPagerSnapHelper.findSnapView(mLayoutManager);
        View snapView2  mLayoutManager.findViewByPosition(snapPosition);
        if (snapView1 ! snapView2) {
            throw new IllegalStateException("Design assumption violated.");

This is how I’m updating the adapter list:

adapter.list  newList
viewpager.setCurrentItem(0, true)

It happens only when smoothScroll is set to true

What am I missing?

Edit : I’m using androidx.viewpager2.widget.ViewPager2 available in


I had this same problem with ViewPager2 on configuration change. I’m using:

implementation ''
implementation 'androidx.viewpager2:viewpager2:1.0.0-beta03'

In my case, I had overridden the getItemId() method in my FragmentStateAdapter class. When I got rid of my getItemId() method, the “IllegalStateException: Design assumption violated” error was no more! 🙂

Answered By – ban-geoengineering

Leave a Comment