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.02k stars 5.41k forks source link

Getting NPE in 6.0.0 version at com.airbnb.lottie.model.layer.SolidLayer.drawLayer(SolidLayer.java:43) #2272

Closed sandeepyohans closed 1 year ago

sandeepyohans commented 1 year ago

Hi @gpeal @bodymovin, I am getting NPE in 6.0.0 version also. Upgraded Lottie version in my Android app from 4.1.0 for the same issue. Checked it on Android 10 and 12. What shall I do?

java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
                    at com.airbnb.lottie.model.layer.SolidLayer.drawLayer(SolidLayer.java:43)
                    at com.airbnb.lottie.model.layer.BaseLayer.draw(BaseLayer.java:259)
                    at com.airbnb.lottie.model.layer.CompositionLayer.drawLayer(CompositionLayer.java:128)
                    at com.airbnb.lottie.model.layer.BaseLayer.draw(BaseLayer.java:259)
                    at com.airbnb.lottie.LottieDrawable.renderAndDrawAsBitmap(LottieDrawable.java:1496)
                    at com.airbnb.lottie.LottieDrawable.draw(LottieDrawable.java:525)
                    at android.widget.ImageView.onDraw(ImageView.java:1442)
                    at android.view.View.draw(View.java:22644)
                    at android.view.View.updateDisplayListIfDirty(View.java:21519)
                    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
                    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
                    at android.view.View.updateDisplayListIfDirty(View.java:21475)
                    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
                    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
                    at android.view.View.updateDisplayListIfDirty(View.java:21475)
                    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
                    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
                    at android.view.View.updateDisplayListIfDirty(View.java:21475)
                    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
                    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
                    at android.view.View.updateDisplayListIfDirty(View.java:21475)
                    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
                    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
                    at android.view.View.updateDisplayListIfDirty(View.java:21475)
                    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
                    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
                    at android.view.View.updateDisplayListIfDirty(View.java:21475)
                    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
                    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
                    at android.view.View.updateDisplayListIfDirty(View.java:21475)
                    at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:534)
                    at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:540)
                    at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:616)
                    at android.view.ViewRootImpl.draw(ViewRootImpl.java:4421)
                    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4149)
                    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3309)
                    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2126)
                    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8658)
                    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1037)
                    at android.view.Choreographer.doCallbacks(Choreographer.java:845)
                    at android.view.Choreographer.doFrame(Choreographer.java:780)
                    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1022)
                    at android.os.Handler.handleCallback(Handler.java:938)
                    at android.os.Handler.dispatchMessage(Handler.java:99)
                    at android.os.Looper.loopOnce(Looper.java:201)
                    at android.os.Looper.loop(Looper.java:288)
                    at android.app.ActivityThread.main(ActivityThread.java:7839)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

Originally posted by @sandeepyohans in https://github.com/airbnb/lottie-android/issues/2083#issuecomment-1491764878

sandeepyohans commented 1 year ago

I got it working by changing my animation json file.

brookmg commented 1 year ago

@sandeepyohans Can you tell us what your changed and the example animation json?

sandeepyohans commented 1 year ago

Hi @brookmg The exception was introduced after removing two layers from animation using Adobe AE. I opened my animation file (which was working fine) in online lottie editor. I removed the layers which I did not want and exported it in dotLottie format. This worked for me.

My animation file has more that 70k lines so won't be able to create a sample json here.

brookmg commented 1 year ago

Alright, thanks. Can you perhaps share the layers you removed from the file? It might help debug what's causing the issue.

gpeal commented 1 year ago

Going to close this since this animation was manually modified and it's possible that you produced an invalid animation as a result.