{"record":{"id":"ec5a36d39549d136","repo":"ybq/Android-SpinKit","slug":"the-fractions-length-must-equal-values-length-fraction","errorCode":null,"errorMessage":"The fractions.length must equal values.length, fraction.length[%d], values.length[%d]","messagePattern":"The fractions\\.length must equal values\\.length, fraction\\.length\\[(.+?)\\], values\\.length\\[(.+?)\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/github/ybq/android/spinkit/animation/SpriteAnimatorBuilder.java","lineNumber":135,"sourceCode":"    public SpriteAnimatorBuilder translateYPercentage(float[] fractions, Float... translateYPercentage) {\n        holder(fractions, Sprite.TRANSLATE_Y_PERCENTAGE, translateYPercentage);\n        return this;\n    }\n\n    private void holder(float[] fractions, Property property, Float[] values) {\n        ensurePair(fractions.length, values.length);\n        fds.put(property.getName(), new FloatFrameData(fractions, property, values));\n    }\n\n\n    private void holder(float[] fractions, Property property, Integer[] values) {\n        ensurePair(fractions.length, values.length);\n        fds.put(property.getName(), new IntFrameData(fractions, property, values));\n    }\n\n    private void ensurePair(int fractionsLength, int valuesLength) {\n        if (fractionsLength != valuesLength) {\n            throw new IllegalStateException(String.format(\n                    Locale.getDefault(),\n                    \"The fractions.length must equal values.length, \" +\n                            \"fraction.length[%d], values.length[%d]\",\n                    fractionsLength,\n                    valuesLength));\n        }\n    }\n\n\n    public SpriteAnimatorBuilder interpolator(Interpolator interpolator) {\n        this.interpolator = interpolator;\n        return this;\n    }\n\n    public SpriteAnimatorBuilder easeInOut(float... fractions) {\n        interpolator(KeyFrameInterpolator.easeInOut(\n                fractions\n        ));","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/ybq/Android-SpinKit/blob/aa83e4d0a42c76eae15e8b18b79aa2a231cca5f8/library/src/main/java/com/github/ybq/android/spinkit/animation/SpriteAnimatorBuilder.java#L117-L153","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nnew SpriteAnimatorBuilder(this).floatInt(new float[]{0f, 0.5f, 1f}, 0, 255); // 3 fractions, 2 values\n// after\nnew SpriteAnimatorBuilder(this).floatInt(new float[]{0f, 0.5f, 1f}, 0, 255, 0); // 3 fractions, 3 values","handlingStrategy":"validation","validationCode":"if (fractions.length != values.length) throw new IllegalArgumentException(\"fractions and values must have equal length\");\nnew SpriteAnimatorBuilder(sprite).floatInt(fractions, values...);","typeGuard":null,"tryCatchPattern":"try { builder.floatInt(fractions, v0, v1, v2); } catch (IllegalStateException e) { Log.e(TAG, \"Keyframe arrays length mismatch\", e); }","preventionTips":["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"],"tags":["android","animation","keyframe","array-length-mismatch"],"backgroundTag":"invalid-argument-value","analyzedSha":"aa83e4d0a42c76eae15e8b18b79aa2a231cca5f8","analyzedAt":"2026-09-12T17:13:52.255Z","contentChangedAt":"2026-09-12T17:13:52.255Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}