airbnb / lottie-android

Render After Effects animations natively on Android and iOS, Web, and React Native
http://airbnb.io/lottie/
Apache License 2.0
35.03k stars 5.41k forks source link

android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. #1292

Closed tianyingzhong closed 5 years ago

tianyingzhong commented 5 years ago

uncaughtException: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. at android.view.ViewRootImplcheckThread(ViewRootImpl.java:7020) at android.view.ViewRootImplrequestLayout(ViewRootImpl.java:1108) at android.view.ViewrequestLayout(View.java:19810) at android.view.ViewrequestLayout(View.java:19810) at android.view.ViewrequestLayout(View.java:19810) at android.view.ViewrequestLayout(View.java:19810) at android.view.ViewrequestLayout(View.java:19810) at android.widget.ImageViewsetImageDrawable(ImageView.java:529) at android.support.v7.widget.AppCompatImageViewsetImageDrawable(TbsSdkJava:99) at com.airbnb.lottie.LottieAnimationViewa(TbsSdkJava:179) at com.airbnb.lottie.LottieAnimationViewsetImageDrawable(TbsSdkJava:171) at com.airbnb.lottie.LottieAnimationViewsetComposition(TbsSdkJava:419) at com.airbnb.lottie.LottieAnimationView$1onResult(TbsSdkJava:62) at com.airbnb.lottie.LottieAnimationView$1onResult(TbsSdkJava:60) at com.airbnb.lottie.ma(TbsSdkJava:153) at com.airbnb.lottie.ma(TbsSdkJava:26) at com.airbnb.lottie.m$1run(TbsSdkJava:140) at android.os.HandlerhandleCallback(Handler.java:754) at android.os.HandlerdispatchMessage(Handler.java:95) at android.os.Looperloop(Looper.java:163) at android.app.ActivityThreadmain(ActivityThread.java:6388) at java.lang.reflect.Methodinvoke(Method.java:-2) at com.android.internal.os.ZygoteInit$MethodAndArgsCallerrun(ZygoteInit.java:930) at com.android.internal.os.ZygoteInitmain(ZygoteInit.java:820)

tianyingzhong commented 5 years ago

已解决

RedBencity commented 5 years ago

请问一下怎么解决的

Charlottenpl commented 1 year ago

可能的原因是Unity导出的项目中默认的线程是UnityMain,不是主线程main,需要在runOnUiThread里面使用