'RecyclerView Crashes when delete first item if 'setHasStableIds(true)' is in adapter

My RecyclerView crashes if I set

init{
   setHasStableIds(true)
}

in my ListAdapter. If I remove this code it works without any issue. Logcat below

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.starsolutions.starfilemanager, PID: 10919
    java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 0(offset:-1).state:2 androidx.recyclerview.widget.RecyclerView{4a24664 VFED..... ......ID 0,147-1080,1878 #7f080181 app:id/rvExplorer}, adapter:com.starsolutions.starfilemanager.ui.ExplorerAdapter@efe3a61, layout:androidx.recyclerview.widget.LinearLayoutManager@e9986, context:com.starsolutions.starfilemanager.MainActivity@a4f9b5f
        at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6183)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source