1

有人为我制作了这个 Lottie 动画:https ://lottiefiles.com/share/DO3Kpo

它似乎在 iOS 上运行良好,但在 Android 上它会引发以下异常。我们尝试了很多,但我们无法弄清楚问题可能是什么。有人对此有任何想法吗?

Java.Lang.IllegalStateException: Unable to parse composition ---> Java.Lang.IllegalArgumentException: The Path cannot loop back on itself.
  at java.lang.IllegalArgumentException: The Path cannot loop back on itself.
  at at android.view.animation.PathInterpolator.initPath(PathInterpolator.java:185)
  at at android.view.animation.PathInterpolator.initCubic(PathInterpolator.java:158)
  at at android.view.animation.PathInterpolator.<init>(PathInterpolator.java:89)
  at at android.support.v4.view.animation.PathInterpolatorCompat.create(PathInterpolatorCompat.java:82)
  at at com.airbnb.lottie.parser.KeyframeParser.parseKeyframe(KeyframeParser.java:130)
  at at com.airbnb.lottie.parser.KeyframeParser.parse(KeyframeParser.java:58)
  at at com.airbnb.lottie.parser.PathKeyframeParser.parse(PathKeyframeParser.java:21)
  at at com.airbnb.lottie.parser.AnimatablePathValueParser.parse(AnimatablePathValueParser.java:29)
  at at com.airbnb.lottie.parser.AnimatablePathValueParser.parseSplitPath(AnimatablePathValueParser.java:55)
  at at com.airbnb.lottie.parser.AnimatableTransformParser.parse(AnimatableTransformParser.java:54)
  at at com.airbnb.lottie.parser.LayerParser.parse(LayerParser.java:99)
  at at com.airbnb.lottie.parser.LottieCompositionParser.parseAssets(LottieCompositionParser.java:147)
  at at com.airbnb.lottie.parser.LottieCompositionParser.parse(LottieCompositionParser.java:77)
  at at com.airbnb.lottie.LottieCompositionFactory.fromJsonReaderSyncInternal(LottieCompositionFactory.java:248)
  at at com.airbnb.lottie.LottieCompositionFactory.fromJsonReaderSync(LottieCompositionFactory.java:242)
  at at com.airbnb.lottie.LottieCompositionFactory.fromJsonInputStreamSync(LottieCompositionFactory.java:177)
  at at com.airbnb.lottie.LottieCompositionFactory.fromJsonInputStreamSync(LottieCompositionFactory.java:171)
  at at com.airbnb.lottie.LottieCompositionFactory.fromAssetSync(LottieCompositionFactory.java:114)
  at at com.airbnb.lottie.LottieCompositionFactory$2.call(LottieCompositionFactory.java:95)
  at at com.airbnb.lottie.LottieCompositionFactory$2.call(LottieCompositionFactory.java:93)
  at at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
  at at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
  at at java.lang.Thread.run(Thread.java:764)
4

2 回答 2

1

我认为您可以在https://github.com/airbnb/lottie-android/issues打开一个问题

分享到 json 的链接,他们可能会调查这个问题。

我可以在这里重现它。它发生在 Android 上只是因为异常发生在 Android 类中:

// Note the class path: android.view.animation.PathInterpolator
at at android.view.animation.PathInterpolator.initPath(PathInterpolator.java:185)
at at android.view.animation.PathInterpolator.initCubic(PathInterpolator.java:158)
at at android.view.animation.PathInterpolator.<init>(PathInterpolator.java:89)
at at android.support.v4.view.animation.PathInterpolatorCompat.create(PathInterpolatorCompat.java:82)
at at com.airbnb.lottie.parser.KeyframeParser.parseKeyframe(KeyframeParser.java:130)

检查源代码PathInterpolator

float fraction = pointComponents[componentIndex++];
float x = pointComponents[componentIndex++];
float y = pointComponents[componentIndex++];
if (fraction == prevFraction && x != prevX) {
    throw new IllegalArgumentException(
            "The Path cannot have discontinuity in the X axis.");
}
if (x < prevX) {
    // Exception is being triggered here due to x < prevX
    throw new IllegalArgumentException("The Path cannot loop back on itself.");
}

PathInterpolatorLottie 库正在调用。因此,他们可能会就此问题提供更好的反馈。

在那里尝试:https ://github.com/airbnb/lottie-android/issues

请注意,他们需要 AEP 文件。因此,与您的朋友交谈以获取该文件:

压缩您的 After Effects AEP 文件并将其附加。如果您的问题没有 AEP 或没有给出明确的理由,您的问题将被自动关闭。

于 2019-11-28T20:23:47.367 回答
0

调试后我发现了问题。那里有两个同名的层,它们引起了冲突。不确定这是否是 Lottie for Android 中的错误,初始版本在 iOS 中运行良好。因此,请确保每一层都有不同的名称;-)

于 2019-12-04T18:44:23.507 回答