umano/AndroidSlidingUpPanel · error · java.lang.IllegalStateException
Cannot settleCapturedViewAt outside of a call to…
Error message
Cannot settleCapturedViewAt outside of a call to Callback#onViewReleased
What it means
settleCapturedViewAt() may only be invoked from inside Callback.onViewReleased(), while mReleaseInProgress is true. Calling it elsewhere throws IllegalStateException because settle logic depends on release-time velocity tracking state.
Solutions
- Move the call into Callback.onViewReleased
- For programmatic settling outside a drag, use smoothSlideViewTo + continueSettling instead
- Use forceSettleCapturedViewAt only if you understand it bypasses the guard
Example fix
// before
public void onViewPositionChanged(View child, int l, int t, int dx, int dy) {
mDragHelper.settleCapturedViewAt(l, t);
}
// after
@Override
public void onViewReleased(View releasedChild, float xvel, float yvel) {
mDragHelper.settleCapturedViewAt(finalLeft, finalTop);
} Defensive patterns
Strategy: validation
Validate before calling
if (mDragHelper.getViewDragState() == ViewDragHelper.STATE_DRAGGING && !inOnViewReleased) {
// settle via smoothSlideViewTo instead
mDragHelper.smoothSlideViewTo(captured, finalLeft, finalTop);
ViewCompat.postInvalidateOnAnimation(container);
} Try / catch
try { mDragHelper.settleCapturedViewAt(l, t); } catch (IllegalStateException e) { mDragHelper.smoothSlideViewTo(view, l, t); } Prevention
- Only call settleCapturedViewAt inside onViewReleased
- Use smoothSlideViewTo + continueSettling for programmatic settling
- Never call drag-helper settle APIs from UI events
When it happens
Trigger: Calling settleCapturedViewAt from onViewCaptured, onViewPositionChanged, computeScroll, or any app code outside onViewReleased.
Common situations: Developers trying to programmatically animate the captured view after drag ends, or reusing AOSP ViewDragHelper sample code in the wrong callback.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Cannot flingCapturedView outside of a call to…
- Parent view may not be null
- Callback may not be null
- captureChildView: parameter must be a descendant of the…
- gravity must be set to either top or bottom
AI-assisted analysis of umano/AndroidSlidingUpPanel@45a460435b (2026-09-11).
Data as JSON: /api/errors/a31005f806bfa88a.
Report an issue: GitHub.
Appendix: source
Thrown at library/src/main/java/com/sothree/slidinguppanel/ViewDragHelper.java:589
mActivePointerId = INVALID_POINTER;
return forceSettleCapturedViewAt(finalLeft, finalTop, 0, 0);
}
/**
* Settle the captured view at the given (left, top) position.
* The appropriate velocity from prior motion will be taken into account.
* If this method returns true, the caller should invoke {@link #continueSettling(boolean)}
* on each subsequent frame to continue the motion until it returns false. If this method
* returns false there is no further work to do to complete the movement.
*
* @param finalLeft Settled left edge position for the captured view
* @param finalTop Settled top edge position for the captured view
* @return true if animation should continue through {@link #continueSettling(boolean)} calls
*/
public boolean settleCapturedViewAt(int finalLeft, int finalTop) {
if (!mReleaseInProgress) {
throw new IllegalStateException("Cannot settleCapturedViewAt outside of a call to " +
"Callback#onViewReleased");
}
return forceSettleCapturedViewAt(finalLeft, finalTop,
(int) VelocityTrackerCompat.getXVelocity(mVelocityTracker, mActivePointerId),
(int) VelocityTrackerCompat.getYVelocity(mVelocityTracker, mActivePointerId));
}
/**
* Settle the captured view at the given (left, top) position.
*
* @param finalLeft Target left position for the captured view
* @param finalTop Target top position for the captured view
* @param xvel Horizontal velocity
* @param yvel Vertical velocity
* @return true if animation should continue through {@link #continueSettling(boolean)} calls
*/
private boolean forceSettleCapturedViewAt(int finalLeft, int finalTop, int xvel, int yvel) {View on GitHub (pinned to 45a460435b)