ybq/Android-SpinKit · error · IllegalStateException
The fractions.length must equal values.length…
Error message
The fractions.length must equal values.length, fraction.length[%d], values.length[%d]
What it means
SpriteAnimatorBuilder.validate/holder builds keyframe animations where each fraction (0-1 keyframe position) must pair one-to-one with an animated value. ensurePair throws IllegalStateException when the fractions array and values array lengths differ, because PropertyValuesHolder cannot map frames to values unambiguously.
Solutions
- Make fractions.length exactly equal to values.length in the builder call
- Ensure the last fraction is 1f and the first is 0f (first/last must always pair)
- Copy an existing Sprite implementation (e.g. Wave) as a template for correct fraction/value pairing
- If generating arrays programmatically, assert fractions.length == values.length before constructing the builder
Example fix
// before
new SpriteAnimatorBuilder(this).floatInt(new float[]{0f, 0.5f, 1f}, 0, 255); // 3 fractions, 2 values
// after
new SpriteAnimatorBuilder(this).floatInt(new float[]{0f, 0.5f, 1f}, 0, 255, 0); // 3 fractions, 3 values Defensive patterns
Strategy: validation
Validate before calling
if (fractions.length != values.length) throw new IllegalArgumentException("fractions and values must have equal length");
new SpriteAnimatorBuilder(sprite).floatInt(fractions, values...); Try / catch
try { builder.floatInt(fractions, v0, v1, v2); } catch (IllegalStateException e) { Log.e(TAG, "Keyframe arrays length mismatch", e); } Prevention
- Pair every keyframe fraction with exactly one value; count them before building
- Always start fractions at 0f and end at 1f with a value for each
- Model custom sprites on the library's built-in Sprite implementations
- Add a unit test asserting fraction/value array lengths for each custom sprite
When it happens
Trigger: Chaining SpriteAnimatorBuilder methods like floatInt(0, 1, ...) or alpha(float[], ...) with a fractions array whose length differs from the values array, e.g. alpha(0.5f) with two values or fractions {0,0.5,1} with two values.
Common situations: Hand-writing keyframes for a custom spinner sprite and miscounting: forgetting the terminal fraction of 1.0, or adding an extra value for a bounce effect without a matching fraction.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
AI-assisted analysis of ybq/Android-SpinKit@aa83e4d0a4 (2026-09-12).
Data as JSON: /api/errors/ec5a36d39549d136.
Report an issue: GitHub.
Appendix: source
Thrown at library/src/main/java/com/github/ybq/android/spinkit/animation/SpriteAnimatorBuilder.java:135
public SpriteAnimatorBuilder translateYPercentage(float[] fractions, Float... translateYPercentage) {
holder(fractions, Sprite.TRANSLATE_Y_PERCENTAGE, translateYPercentage);
return this;
}
private void holder(float[] fractions, Property property, Float[] values) {
ensurePair(fractions.length, values.length);
fds.put(property.getName(), new FloatFrameData(fractions, property, values));
}
private void holder(float[] fractions, Property property, Integer[] values) {
ensurePair(fractions.length, values.length);
fds.put(property.getName(), new IntFrameData(fractions, property, values));
}
private void ensurePair(int fractionsLength, int valuesLength) {
if (fractionsLength != valuesLength) {
throw new IllegalStateException(String.format(
Locale.getDefault(),
"The fractions.length must equal values.length, " +
"fraction.length[%d], values.length[%d]",
fractionsLength,
valuesLength));
}
}
public SpriteAnimatorBuilder interpolator(Interpolator interpolator) {
this.interpolator = interpolator;
return this;
}
public SpriteAnimatorBuilder easeInOut(float... fractions) {
interpolator(KeyFrameInterpolator.easeInOut(
fractions
));View on GitHub (pinned to aa83e4d0a4)