DrKLO/Telegram · error · IllegalArgumentException
Providing a LayoutTransition into RecyclerView is not suppor
Error message
Providing a LayoutTransition into RecyclerView is not supported. Please use setItemAnimator() instead for animating changes to the items in this RecyclerView
What it means
RecyclerView overrides setLayoutTransition to forbid non-null LayoutTransition. RecyclerView animates children through ItemAnimator, and a ViewGroup LayoutTransition would conflict with the recycler's own add/remove/move bookkeeping, producing broken animations and crashes. Only null is accepted (to clear any inherited transition).
Source
Thrown at TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java:2347
* @return true if layout and scroll are frozen
*
* @deprecated Use {@link #isLayoutSuppressed()}.
*/
@Deprecated
public boolean isLayoutFrozen() {
return isLayoutSuppressed();
}
/**
* @deprecated Use {@link #setItemAnimator(ItemAnimator)} ()}.
*/
@Deprecated
@Override
public void setLayoutTransition(LayoutTransition transition) {
if (transition == null) {
super.setLayoutTransition(null);
} else {
throw new IllegalArgumentException("Providing a LayoutTransition into RecyclerView is "
+ "not supported. Please use setItemAnimator() instead for animating changes "
+ "to the items in this RecyclerView");
}
}
/**
* Animate a scroll by the given amount of pixels along either axis.
*
* @param dx Pixels to scroll horizontally
* @param dy Pixels to scroll vertically
*/
public void smoothScrollBy(@Px int dx, @Px int dy) {
smoothScrollBy(dx, dy, null);
}
/**
* Animate a scroll by the given amount of pixels along either axis.
*View on GitHub (pinned to 45ab8f4308)
Solutions
- Remove android:animateLayoutChanges="true" from the RecyclerView element in XML.
- Do not call setLayoutTransition on a RecyclerView; use setItemAnimator(DefaultItemAnimator) for change animations.
- Call recyclerView.setLayoutTransition(null) defensively if a theme/style injects one.
Example fix
<!-- before -->
<androidx.recyclerview.widget.RecyclerView
android:animateLayoutChanges="true" .../>
<!-- after -->
<androidx.recyclerview.widget.RecyclerView .../> <!-- no animateLayoutChanges --> Defensive patterns
Strategy: validation
Validate before calling
// Never call setLayoutTransition(non-null) on a RecyclerView. // If a theme may inject one, clear it explicitly: recyclerView.setLayoutTransition(null);
Type guard
null
Try / catch
null
Prevention
- Do not set android:animateLayoutChanges on a RecyclerView.
- Use DefaultItemAnimator via setItemAnimator for change animations.
- If a shared style injects a transition, override with setLayoutTransition(null) after inflation.
When it happens
Trigger: Calling recyclerView.setLayoutTransition(someTransition) programmatically. Setting android:animateLayoutChanges="true" on the RecyclerView in XML (which installs a default LayoutTransition). Applying a layout transition via a shared style/theme.
Common situations: Copy-pasting android:animateLayoutChanges="true" from another ViewGroup into the RecyclerView. Programmatically applying a global transition to all ViewGroups in a hierarchy walk.
Related errors
- only remove and update ops can be dispatched in first pass
- Invalid orientation. It should be either HORIZONTAL or VERTI
- GridLayoutManager does not support stack from end. Consider
- Item at position {} requires {} spans but GridLayoutManager
- Span count should be at least 1. Provided {}
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/a511d0c74fa15c2b.
Report an issue: GitHub.