question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Two different ViewHolders have the same stable ID. Stable IDs in your adapter MUST BE unique and SHOULD NOT change.

See original GitHub issue

I was trying to add multiple viewTypes, and this happens…

java.lang.IllegalStateException: Two different ViewHolders have the same stable ID. Stable IDs in your adapter MUST BE unique and SHOULD NOT change. ViewHolder 1:EpoxyViewHolder{epoxyModel=MunchRestaurantPricesModel_{providerImage=http://myhubber.me/img/backend/provider/zomato.com/logo.png, munchOffer=Standard Price, providerColor=#C9202D}MunchRestaurantPricesModel_{id=71503083113255448, viewType=2131558538, shown=true, addedToAdapter=false}, view=com.google.android.material.card.MaterialCardView{b62be44 VFE...C.. ......ID 56,1078-1384,1289}, super=EpoxyViewHolder{1fdf6c3 position=1 id=71503083113255448, oldPos=-1, pLpos:-1}} View Holder 2:EpoxyViewHolder{epoxyModel=MunchRestaurantPricesModel_{providerImage=http://myhubber.me/img/backend/provider/talabat.com/logo.png, munchOffer=Standard Price, providerColor=#FF6F00}MunchRestaurantPricesModel_{id=71503083113255448, viewType=2131558538, shown=true, addedToAdapter=false}, view=com.google.android.material.card.MaterialCardView{b9beb2d VFE...C.. ......ID 56,1345-1384,1556}, super=EpoxyViewHolder{d05c9a0 position=2 id=71503083113255448, oldPos=-1, pLpos:-1}} com.airbnb.epoxy.EpoxyRecyclerView{4d90862 VFED..... ......ID 0,0-1440,2722 #7f0a0222 app:id/restaurantRecycler}, adapter:com.airbnb.epoxy.EpoxyControllerAdapter@ec29df3, layout:androidx.recyclerview.widget.LinearLayoutManager@1ef7ab0, context:com.myhubber.myhubberr.ui.activities.munchItemDetails.MunchItemDetailsActivity@d67598a

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
elihartcommented, Jun 9, 2021

epoxy hashes it for you. you should not be implementing getItemId, the base EpoxyModel class handles that. just set your id with id. look at the source

2reactions
dinhlamvncommented, Jun 13, 2020

@Chullian Let check your buildModels code in EpoxyController. Please make sure the id of each model view is unique.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Two different ViewHolders have the same stable ID - Stack ...
java.lang.IllegalStateException: Two different ViewHolders have the same stable ID. Stable IDs in your adapter MUST BE unique and SHOULD NOT change.
Read more >
alipay404 / epoxy Download - JitPack
It abstracts the boilerplate of view holders, item types, item ids, span counts, and more, in order to simplify building screens with multiple...
Read more >
Epoxy for Android - Airbnb Engineering & Data Science
Epoxy is an Android library for building complex screens in a RecyclerView. It abstracts the boilerplate of view holders, item types, item ids,...
Read more >
Repeated IDs cause NullPointerException from RecyclerView ...
Most likely caused by two viewholder having the same id. ... So, we should see the error "Stable IDs in your adapter MUST...
Read more >
Tutorial - Advanced RecyclerView
If adapter does not return stable & unique IDs, that will cause some weird behaviors (wrong animations, NPE, etc...) class MyAdapter extends RecyclerView....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found