private LinearGradient getLinearGradient() {
    int gradientHash = getGradientHash();
    LinearGradient gradient = linearGradientCache.get(gradientHash);
    if (gradient != null) {
      return gradient;
    }
    PointF startPoint = startPointAnimation.getValue();
    PointF endPoint = endPointAnimation.getValue();
    GradientColor gradientColor = colorAnimation.getValue();
    int[] colors = applyDynamicColorsIfNeeded(gradientColor.getColors());
    float[] positions = gradientColor.getPositions();

    // Add check for minimum colors
    if (colors.length < 2) {
      // If only one color, duplicate it to create a solid color gradient
      colors = new int[]{colors[0], colors[0]};
      positions = new float[]{0f, 1f};
    }
    
    gradient = new LinearGradient(startPoint.x, startPoint.y, endPoint.x, endPoint.y, colors,
        positions, Shader.TileMode.CLAMP);
    linearGradientCache.put(gradientHash, gradient);
    return gradient;
  }
Cache the gradients such that it runs at 30fps.
lottie/src/main/java/com/airbnb/lottie/animation/content/GradientFillContent.java