lottie-android: Bug: Weird crash when showing a Lottie animation : "Invalid Layer Save Flag"

Tested on Pixel 2 with Android P DP3. I tried to disable hardware acceleration. Didn’t help. Version 2.5.5 of the library, but also on 2.5.4 (updated because I was hoping it will fix it). Doesn’t seem to occur on older Android versions. Also, file can be shown just fine via the sample Lottie app from the Play Store. I see some logs of this sort, before the crash.

E/AbstractTracker: Can’t create handler inside thread that has not called Looper.prepare()

But I can’t find out where this occurs, and can’t see which class cause it.

I’ve also noticed that another animation of Lottie also causes this crash, but another doesn’t.

This is how we use it:

<...LottieAnimationViewEx
    android:layout_width="@dimen/please_wait_big__animation_size" android:layout_height="@dimen/please_wait_big__animation_size" app:lottie_autoPlay="true"
    app:lottie_loop="true" app:lottie_rawRes="@raw/please_wait_big"
    tools:src="@android:drawable/sym_def_app_icon"/>

And this is the code of the LottieAnimationViewEx class:

class LottieAnimationViewEx @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : LottieAnimationView(context, attrs, defStyleAttr) {

    init{
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
            useHardwareAcceleration(true)
    }

}

This is what I get in logs :

2018-06-11 10:17:25.666 27443-27443/… E/AndroidRuntime: FATAL EXCEPTION: main Process: …, PID: 27443 java.lang.IllegalArgumentException: Invalid Layer Save Flag - only ALL_SAVE_FLAGS is allowed at android.graphics.Canvas.checkValidSaveFlags(Canvas.java:378) at android.graphics.Canvas.saveLayer(Canvas.java:455) at com.airbnb.lottie.model.layer.BaseLayer.draw(BaseLayer.java:224) at com.airbnb.lottie.model.layer.CompositionLayer.drawLayer(CompositionLayer.java:100) at com.airbnb.lottie.model.layer.BaseLayer.draw(BaseLayer.java:190) at com.airbnb.lottie.LottieDrawable.draw(LottieDrawable.java:312) at android.widget.ImageView.onDraw(ImageView.java:1360) at android.view.View.draw(View.java:20205) at android.view.View.updateDisplayListIfDirty(View.java:19080) at android.view.View.draw(View.java:19933) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.draw(View.java:20208) at android.view.View.updateDisplayListIfDirty(View.java:19080) at android.view.View.draw(View.java:19933) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.updateDisplayListIfDirty(View.java:19071) at android.view.View.draw(View.java:19933) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.updateDisplayListIfDirty(View.java:19071) at android.view.View.draw(View.java:19933) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.draw(View.java:20208) at com.android.internal.policy.DecorView.draw(DecorView.java:780) at android.view.View.updateDisplayListIfDirty(View.java:19080) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:685) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:691) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:799) at android.view.ViewRootImpl.draw(ViewRootImpl.java:3263) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3079) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2459) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1447) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7130) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:935) at android.view.Choreographer.doCallbacks(Choreographer.java:747) at android.view.Choreographer.doFrame(Choreographer.java:682) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:921) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6642) 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:858)

I wanted to create a new POC with this issue, and publish here, but then I got this weird error, just by adding the dependency of Lottie :

image

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:app:transformDexArchiveWithExternalLibsDexMergerForDebug’.

com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\0.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\1.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\2.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\3.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\4.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\5.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\6.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\7.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\8.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\9.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\10.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\11.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\12.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\13.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\14.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\15.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\16.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\18.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\19.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\21.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\23.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\24.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\25.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\26.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\27.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\28.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\29.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\30.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\31.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\32.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\33.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\34.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\35.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\36.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\37.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\38.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\39.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\40.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\41.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\42.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\43.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\44.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\45.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\46.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\48.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\49.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\50.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\51.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\52.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\53.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\54.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\55.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\56.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\57.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\58.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\59.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\61.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\62.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\63.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\64.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\65.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\66.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\67.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\68.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\69.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\70.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\71.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\72.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\73.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\74.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\75.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\76.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\77.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\78.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\79.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\80.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\81.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\82.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\83.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\84.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\85.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\86.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\87.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\88.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\89.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\90.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\91.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\92.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\93.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\94.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\95.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\96.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\97.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\98.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\99.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\100.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\101.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\102.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\103.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\104.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\105.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\106.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\107.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\108.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\109.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\110.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\111.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\113.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\114.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\115.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\117.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\118.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\119.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\120.jar, C:\Users\User\AndroidStudioProjects\MyApplication7\app\build\intermediates\transforms\dexBuilder\debug\121.jar

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

What’s going on?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 35

Most upvoted comments

implementation 'com.airbnb.android:lottie:2.7.0' fixes the issue

Yeah, 2.5.7 seemed to be broken for me too, and had nothing more than 2.5.6 so I did take 2.5.6 too to fix the problem.

I started seeing this on DP3, when I updated the target SDK to 28. Not all animations crash, but the one posted above, does.

Everything still works fine on older versions of Android, with the target SDK of 28.

@sh3r1 Yes, 2.8.0 requires androidx.

@gpeal I used implementation ‘com.airbnb.android:lottie:2.5.5’ and experiences the same issue once upgrade to Android P. I would appreciate if this fix got released. Thanks

I was just commenting to clarify that it happens when updating the target SDK to 28. Being on DP3 alone does not force this error. I do not know why it happens yet and do not know enough to say if it is an issue with Lottie or with Android.

Since it happens on the target SDK update, it would appear that this is a new platform restriction that will either need implemented in Lottie, or, we will need more information on how to build animations that will work with this new restriction.

@voidstarfire Better ask this in a new issue…

Any chance there will be a release at some point soon that includes this? @gpeal