gpt4 book ai didi

java - 洛蒂错误 : "java.lang.IllegalStateException: Unable to parse composition"

转载 作者:行者123 更新时间:2023-12-05 00:11:53 27 4
gpt4 key购买 nike

我正在尝试将 LottieAnimationView 添加到我的项目中的 xml 布局中,但出现此异常:“java.lang.IllegalStateException: Unable to parse composition”。

java.lang.IllegalStateException: Unable to parse composition
at com.airbnb.lottie.LottieAnimationView$1.onResult(LottieAnimationView.java:78)
at com.airbnb.lottie.LottieAnimationView$1.onResult(LottieAnimationView.java:71)
at com.airbnb.lottie.LottieAnimationView$3.onResult(LottieAnimationView.java:95)
at com.airbnb.lottie.LottieAnimationView$3.onResult(LottieAnimationView.java:88)
at com.airbnb.lottie.LottieTask.notifyFailureListeners(LottieTask.java:158)
at com.airbnb.lottie.LottieTask.access$200(LottieTask.java:27)
at com.airbnb.lottie.LottieTask$1.run(LottieTask.java:133)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7860)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
Caused by: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Failed resolution of: Lokio/Okio;
at java.util.concurrent.FutureTask.report(FutureTask.java:123)
at java.util.concurrent.FutureTask.get(FutureTask.java:193)
at com.airbnb.lottie.LottieTask$LottieFutureTask.done(LottieTask.java:175)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lokio/Okio;
at com.airbnb.lottie.LottieCompositionFactory.fromRawResSync(LottieCompositionFactory.java:265)
at com.airbnb.lottie.LottieCompositionFactory$3.call(LottieCompositionFactory.java:234)
at com.airbnb.lottie.LottieCompositionFactory$3.call(LottieCompositionFactory.java:229)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:919) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "okio.Okio" on path: DexPathList[[zip file "/data/app/com.create.loop-D3ZAa0jgAPGefDD0MoGI3A==/base.apk"],nativeLibraryDirectories=[/data/app/com.create.loop-D3ZAa0jgAPGefDD0MoGI3A==/lib/arm, /system/lib, /vendor/lib, /system/product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.airbnb.lottie.LottieCompositionFactory.fromRawResSync(LottieCompositionFactory.java:265) 
at com.airbnb.lottie.LottieCompositionFactory$3.call(LottieCompositionFactory.java:234) 
at com.airbnb.lottie.LottieCompositionFactory$3.call(LottieCompositionFactory.java:229) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:919) 

部分 XML 布局:

    <com.airbnb.lottie.LottieAnimationView
android:id="@+id/animationView"
android:layout_width="50dp"
android:layout_height="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:lottie_rawRes="@raw/heart_beat" />

有趣的是,当我创建一个新的测试项目并将上面的代码粘贴到新创建的 activity_main.xml 中时,一切都在新项目中完美运行。

我尝试将 app:lottie_rawRes="@raw/heart_beat" 替换为 app:lottie_fileName="heart_beat.json"(来自 assets 文件夹),但仍然没有结果.我该如何解决这个问题?谢谢。

最佳答案

如果你只想避免崩溃,你可以在设置动画之前设置lottie失败监听器而不是默认监听器。

lottieView.setFailureListener { t ->
//do on error
}
lottieView.setAnimation(...)

关于java - 洛蒂错误 : "java.lang.IllegalStateException: Unable to parse composition",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65360311/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com