Lottie-android: needs >= 2 number of colors

Created on 25 May 2017  路  12Comments  路  Source: airbnb/lottie-android

Hi,
I have received 4 json files from my designer after export from After Effects. One of them works fine but get the following Exception with others:
"java.lang.IllegalArgumentException: needs >= 2 number of colors"
Any help towards resolving this issue?
Thanks in Advance

Most helpful comment

Same problem came up to me, and here is my json file, any help will be appreciated.It blocked me for a long time.
data.json.zip

All 12 comments

Can you post the full stack and the aep file?

@bijuC1983

@gpeal Sure. I shall get aep files from the design team on Monday & post it here along with the trace.

@bijuC1983 one potential thing is that if there are gradients, you have to save your composition before bodymovin will pick up the change.

@gpeal You may find the aep file & the jsons here http://bit.ly/2rjaS1b
The message I received from the design team is that there are no gradients, but only flat colors.
The trace is here https://pastebin.com/raw/Yp2bfPMF

@bijuC1983 A few things stand out already.
1) Right click any illustrator layers and convert them to shape layers. This will allow Lottie to render them as shapes instead of exporting them as pngs. For reference, you should never need lots of pngs for a Lottie animation.
2) Lottie doesn't yet support text so you'll want to remove those layers.
3) Lottie doesn't support time remaping (yet)

The issue you're facing is on the gradient stroke. For now you can remove that but I'll look in to it more.

@gpeal I have the same problem!No png! And my designer promise me no text!
And what is time remaping?

java.lang.IllegalArgumentException: needs >= 2 number of colors
at android.graphics.LinearGradient.(LinearGradient.java:55)
at com.airbnb.lottie.GradientStrokeContent.getLinearGradient(GradientStrokeContent.java:89)
at com.airbnb.lottie.GradientStrokeContent.draw(GradientStrokeContent.java:57)
at com.airbnb.lottie.ContentGroup.draw(ContentGroup.java:185)
at com.airbnb.lottie.ContentGroup.draw(ContentGroup.java:185)
at com.airbnb.lottie.ShapeLayer.drawLayer(ShapeLayer.java:24)
at com.airbnb.lottie.BaseLayer.draw(BaseLayer.java:162)
at com.airbnb.lottie.CompositionLayer.drawLayer(CompositionLayer.java:75)
at com.airbnb.lottie.BaseLayer.draw(BaseLayer.java:162)
at com.airbnb.lottie.LottieDrawable.draw(LottieDrawable.java:283)
at android.widget.ImageView.onDraw(ImageView.java:1246)
at android.view.View.draw(View.java:16184)
at android.view.View.buildDrawingCacheImpl(View.java:15480)
at android.view.View.buildDrawingCache(View.java:15341)
at android.view.View.draw(View.java:15947)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
at android.view.View.draw(View.java:16187)
at android.view.View.updateDisplayListIfDirty(View.java:15180)
at android.view.View.draw(View.java:15954)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
at android.view.View.updateDisplayListIfDirty(View.java:15175)
at android.view.View.draw(View.java:15954)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
at android.view.View.updateDisplayListIfDirty(View.java:15175)
at android.view.View.draw(View.java:15954)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
at android.view.View.updateDisplayListIfDirty(View.java:15175)
at android.view.View.draw(View.java:15954)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
at android.view.View.updateDisplayListIfDirty(View.java:15175)
at android.view.View.draw(View.java:15954)
at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
at android.view.View.draw(View.java:16187)
at com.android.internal.policy.PhoneWindow$DecorView.draw(PhoneWindow.java:2690)
at android.view.View.updateDisplayListIfDirty(View.java:15180)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:281)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:287)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:322)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2615)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2434)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2067)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

bind.json.zip

Same problem came up to me, and here is my json file, any help will be appreciated.It blocked me for a long time.
data.json.zip

@simensqpg can you post your AE file as well?

@simensqpg
I found the problem
Lottie-android don't have

Currently Unsupported After Effects Features
Even-Odd winding paths
Merge Shapes
Trim Shapes Individually feature of Trim Paths
Expressions
3d Layer support
Gradients
Polystar shapes (Can convert to vector path as a workaround)
Alpha inverted mask

I see it in lottie-ios
my UI told me your json file have Gradients

@quanquanams I need to update that. Lottie does support gradients. There is just a bug with a certain gradient configuration that I have to look in to

Hi, I'm still facing this issue. Wish anyone could help me to fix the issue.

@gpeal , sir?

data.json (1).zip

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leleliu008 picture leleliu008  路  4Comments

anitoledo picture anitoledo  路  4Comments

goldyonwar picture goldyonwar  路  4Comments

nick1Jian picture nick1Jian  路  3Comments

dfpalomar picture dfpalomar  路  5Comments