airbnb / lottie-web

Render After Effects animations natively on Web, Android and iOS, and React Native. http://airbnb.io/lottie/
MIT License
30.53k stars 2.87k forks source link

NullPointerException at com.airbnb.lottie.animation.content.BaseStrokeContent.<init>(BaseStrokeContent.java:65) #1639

Open chenjianping99 opened 5 years ago

chenjianping99 commented 5 years ago

2019-05-22 09:58:29.812 5178-5178/com.vip.lightartdemo E/AndroidRuntime: FATAL EXCEPTION: main Process: com.vip.lightartdemo, PID: 5178 java.lang.NullPointerException: Attempt to invoke virtual method 'com.airbnb.lottie.animation.keyframe.BaseKeyframeAnimation com.airbnb.lottie.model.animatable.AnimatableFloatValue.createAnimation()' on a null object reference at com.airbnb.lottie.animation.content.BaseStrokeContent.(BaseStrokeContent.java:65) at com.airbnb.lottie.animation.content.StrokeContent.(StrokeContent.java:26) at com.airbnb.lottie.model.content.ShapeStroke.toContent(ShapeStroke.java:79) at com.airbnb.lottie.animation.content.ContentGroup.contentsFromModels(ContentGroup.java:30) at com.airbnb.lottie.animation.content.ContentGroup.(ContentGroup.java:60) at com.airbnb.lottie.model.content.ShapeGroup.toContent(ShapeGroup.java:29) at com.airbnb.lottie.animation.content.ContentGroup.contentsFromModels(ContentGroup.java:30) at com.airbnb.lottie.animation.content.ContentGroup.(ContentGroup.java:60) at com.airbnb.lottie.model.layer.ShapeLayer.(ShapeLayer.java:25) at com.airbnb.lottie.model.layer.BaseLayer.forModel(BaseLayer.java:45) at com.airbnb.lottie.model.layer.CompositionLayer.(CompositionLayer.java:52) at com.airbnb.lottie.LottieDrawable.buildCompositionLayer(LottieDrawable.java:243) at com.airbnb.lottie.LottieDrawable.setComposition(LottieDrawable.java:205) at com.airbnb.lottie.LottieAnimationView.setComposition(LottieAnimationView.java:408) at com.airbnb.lottie.LottieAnimationView$1.onResult(LottieAnimationView.java:62) at com.airbnb.lottie.LottieAnimationView$1.onResult(LottieAnimationView.java:60) at com.airbnb.lottie.LottieTask.notifySuccessListeners(LottieTask.java:153) at com.airbnb.lottie.LottieTask.access$200(LottieTask.java:26) at com.airbnb.lottie.LottieTask$1.run(LottieTask.java:140) at android.os.Handler.handleCallback(Handler.java:794) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:173) at android.app.ActivityThread.main(ActivityThread.java:6653) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:821)

just used: LottieAnimationView: .setAnimation(jsonName); .setRepeatCount(-1); .playAnimation(); the Lottie json file is: {"w":72,"assets":[{"w":72,"id":"image_0","u":"images\/","h":72,"p":"img_0.png"}],"v":"4.5.7","ddd":0,"op":76,"layers":[{"ty":2,"op":1800,"ao":0,"ks":{"o":{"k":[{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[100],"t":14.4,"s":[0],"i":{"y":[0.833],"x":[0.833]}},{"t":31.19921875}],"a":1},"s":{"k":[100,100,100],"a":0},"r":{"k":0,"a":0},"a":{"k":[36,36,0],"a":0},"p":{"k":[36,36,0],"a":0}},"ddd":0,"ind":0,"sr":1,"bm":0,"cl":"png","refId":"image_0","st":0,"ip":0,"nm":"star_big_seletced@2x.png"},{"ty":4,"op":1800,"ao":0,"ks":{"o":{"k":[{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[0],"t":0,"s":[0],"i":{"y":[0.833],"x":[0.833]}},{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[100],"t":31.199,"s":[0],"i":{"y":[0.833],"x":[0.833]}},{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[100],"t":33.6,"s":[100],"i":{"y":[0.833],"x":[0.833]}},{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[0],"t":57.6,"s":[100],"i":{"y":[0.833],"x":[0.833]}},{"t":64.80078125}],"a":1},"s":{"k":[70.683,100,100],"a":0},"r":{"k":-20,"a":0},"a":{"k":[0,0,0],"a":0},"p":{"k":[{"to":[-3.16666674613953,1,0],"e":[16.875,44.25,0],"t":48,"s":[35.875,38.25,0],"n":"0p833_0p833_0p167_0p167","o":{"y":0.167,"x":0.167},"ti":[3.16666674613953,-1,0],"i":{"y":0.833,"x":0.833}},{"t":57.599609375}],"a":1}},"ddd":0,"ind":1,"sr":1,"bm":0,"st":0,"ip":0,"shapes":[{"mn":"ADBE Vector Group","ty":"gr","it":[{"mn":"ADBE Vector Shape - Rect","ty":"rc","d":1,"s":{"k":[72,72],"a":0},"r":{"k":18,"a":0},"nm":"Rectangle Path 1","p":{"k":[-36,0],"a":0}},{"mn":"ADBE Vector Graphic - Stroke","w":{"k":0,"a":0},"ty":"st","lj":1,"c":{"k":[1,1,1,1],"a":0},"o":{"k":100,"a":0},"lc":1,"ml":4,"nm":"Stroke 1"},{"mn":"ADBE Vector Graphic - Fill","ty":"fl","o":{"k":100,"a":0},"c":{"k":[1,0.73,0.16,1],"a":0},"nm":"Fill 1"},{"ty":"tr","sk":{"k":0,"ix":4,"a":0},"s":{"k":[23.688,6.441],"ix":3,"a":0},"r":{"k":0,"ix":6,"a":0},"sa":{"k":0,"ix":5,"a":0},"a":{"k":[0,0],"ix":1,"a":0},"p":{"k":[0,0],"ix":2,"a":0},"o":{"k":100,"ix":7,"a":0},"nm":"Transform"}],"np":3,"nm":"Rectangle 1"}],"nm":"Shape Layer 4"},{"ty":4,"op":1800,"ao":0,"ks":{"o":{"k":[{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[0],"t":0,"s":[0],"i":{"y":[0.833],"x":[0.833]}},{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[100],"t":31.199,"s":[0],"i":{"y":[0.833],"x":[0.833]}},{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[100],"t":33.6,"s":[100],"i":{"y":[0.833],"x":[0.833]}},{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[0],"t":57.6,"s":[100],"i":{"y":[0.833],"x":[0.833]}},{"t":64.80078125}],"a":1},"s":{"k":[70.683,100,100],"a":0},"r":{"k":200,"a":0},"a":{"k":[0,0,0],"a":0},"p":{"k":[{"to":[3.16666674613953,0.83333331346512,0],"e":[54.875,43.25,0],"t":48,"s":[35.875,38.25,0],"n":"0p833_0p833_0p167_0p167","o":{"y":0.167,"x":0.167},"ti":[-3.16666674613953,-0.83333331346512,0],"i":{"y":0.833,"x":0.833}},{"t":57.599609375}],"a":1}},"ddd":0,"ind":2,"sr":1,"bm":0,"st":0,"ip":0,"shapes":[{"mn":"ADBE Vector Group","ty":"gr","it":[{"mn":"ADBE Vector Shape - Rect","ty":"rc","d":1,"s":{"k":[72,72],"a":0},"r":{"k":18,"a":0},"nm":"Rectangle Path 1","p":{"k":[-36,0],"a":0}},{"mn":"ADBE Vector Graphic - Stroke","w":{"k":0,"a":0},"ty":"st","lj":1,"c":{"k":[1,1,1,1],"a":0},"o":{"k":100,"a":0},"lc":1,"ml":4,"nm":"Stroke 1"},{"mn":"ADBE Vector Graphic - Fill","ty":"fl","o":{"k":100,"a":0},"c":{"k":[1,0.73,0.16,1],"a":0},"nm":"Fill 1"},{"ty":"tr","sk":{"k":0,"ix":4,"a":0},"s":{"k":[23.688,6.441],"ix":3,"a":0},"r":{"k":0,"ix":6,"a":0},"sa":{"k":0,"ix":5,"a":0},"a":{"k":[0,0],"ix":1,"a":0},"p":{"k":[0,0],"ix":2,"a":0},"o":{"k":100,"ix":7,"a":0},"nm":"Transform"}],"np":3,"nm":"Rectangle 1"}],"nm":"Shape Layer 5"},{"ty":4,"op":1800,"ao":0,"ks":{"o":{"k":[{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[0],"t":0,"s":[0],"i":{"y":[0.833],"x":[0.833]}},{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[100],"t":31.199,"s":[0],"i":{"y":[0.833],"x":[0.833]}},{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[100],"t":33.6,"s":[100],"i":{"y":[0.833],"x":[0.833]}},{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[0],"t":57.6,"s":[100],"i":{"y":[0.833],"x":[0.833]}},{"t":64.80078125}],"a":1},"s":{"k":[70.683,100,100],"a":0},"r":{"k":-90,"a":0},"a":{"k":[0,0,0],"a":0},"p":{"k":[{"to":[0,3.29166674613953,0],"e":[35.875,58,0],"t":48,"s":[35.875,38.25,0],"n":"0p833_0p833_0p167_0p167","o":{"y":0.167,"x":0.167},"ti":[0,-3.29166674613953,0],"i":{"y":0.833,"x":0.833}},{"t":57.599609375}],"a":1}},"ddd":0,"ind":3,"sr":1,"bm":0,"st":0,"ip":0,"shapes":[{"mn":"ADBE Vector Group","ty":"gr","it":[{"mn":"ADBE Vector Shape - Rect","ty":"rc","d":1,"s":{"k":[72,72],"a":0},"r":{"k":18,"a":0},"nm":"Rectangle Path 1","p":{"k":[-36,0],"a":0}},{"mn":"ADBE Vector Graphic - Stroke","w":{"k":0,"a":0},"ty":"st","lj":1,"c":{"k":[1,1,1,1],"a":0},"o":{"k":100,"a":0},"lc":1,"ml":4,"nm":"Stroke 1"},{"mn":"ADBE Vector Graphic - Fill","ty":"fl","o":{"k":100,"a":0},"c":{"k":[1,0.73,0.16,1],"a":0},"nm":"Fill 1"},{"ty":"tr","sk":{"k":0,"ix":4,"a":0},"s":{"k":[23.688,6.441],"ix":3,"a":0},"r":{"k":0,"ix":6,"a":0},"sa":{"k":0,"ix":5,"a":0},"a":{"k":[0,0],"ix":1,"a":0},"p":{"k":[0,0],"ix":2,"a":0},"o":{"k":100,"ix":7,"a":0},"nm":"Transform"}],"np":3,"nm":"Rectangle 1"}],"nm":"Shape Layer 6"},{"ty":4,"op":1800,"ao":0,"ks":{"o":{"k":[{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[0],"t":0,"s":[0],"i":{"y":[0.833],"x":[0.833]}},{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[100],"t":31.199,"s":[0],"i":{"y":[0.833],"x":[0.833]}},{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[100],"t":33.6,"s":[100],"i":{"y":[0.833],"x":[0.833]}},{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[0],"t":57.6,"s":[100],"i":{"y":[0.833],"x":[0.833]}},{"t":64.80078125}],"a":1},"s":{"k":[70.683,100,100],"a":0},"r":{"k":55,"a":0},"a":{"k":[0,0,0],"a":0},"p":{"k":[{"to":[-2.04166674613953,-2.83333325386047,0],"e":[23.625,21.25,0],"t":48,"s":[35.875,38.25,0],"n":"0p833_0p833_0p167_0p167","o":{"y":0.167,"x":0.167},"ti":[2.04166674613953,2.83333325386047,0],"i":{"y":0.833,"x":0.833}},{"t":57.599609375}],"a":1}},"ddd":0,"ind":4,"sr":1,"bm":0,"st":0,"ip":0,"shapes":[{"mn":"ADBE Vector Group","ty":"gr","it":[{"mn":"ADBE Vector Shape - Rect","ty":"rc","d":1,"s":{"k":[72,72],"a":0},"r":{"k":18,"a":0},"nm":"Rectangle Path 1","p":{"k":[-36,0],"a":0}},{"mn":"ADBE Vector Graphic - Stroke","w":{"k":0,"a":0},"ty":"st","lj":1,"c":{"k":[1,1,1,1],"a":0},"o":{"k":100,"a":0},"lc":1,"ml":4,"nm":"Stroke 1"},{"mn":"ADBE Vector Graphic - Fill","ty":"fl","o":{"k":100,"a":0},"c":{"k":[1,0.73,0.16,1],"a":0},"nm":"Fill 1"},{"ty":"tr","sk":{"k":0,"ix":4,"a":0},"s":{"k":[23.688,6.441],"ix":3,"a":0},"r":{"k":0,"ix":6,"a":0},"sa":{"k":0,"ix":5,"a":0},"a":{"k":[0,0],"ix":1,"a":0},"p":{"k":[0,0],"ix":2,"a":0},"o":{"k":100,"ix":7,"a":0},"nm":"Transform"}],"np":3,"nm":"Rectangle 1"}],"nm":"Shape Layer 7"},{"ty":4,"op":1800,"ao":0,"ks":{"o":{"k":[{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[0],"t":0,"s":[0],"i":{"y":[0.833],"x":[0.833]}},{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[100],"t":31.199,"s":[0],"i":{"y":[0.833],"x":[0.833]}},{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[100],"t":33.6,"s":[100],"i":{"y":[0.833],"x":[0.833]}},{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[0],"t":57.6,"s":[100],"i":{"y":[0.833],"x":[0.833]}},{"t":64.80078125}],"a":1},"s":{"k":[70.683,100,100],"a":0},"r":{"k":120,"a":0},"a":{"k":[0,0,0],"a":0},"p":{"k":[{"to":[1.95833337306976,-2.875,0],"e":[47.625,21,0],"t":48,"s":[35.875,38.25,0],"n":"0p833_0p833_0p167_0p167","o":{"y":0.167,"x":0.167},"ti":[-1.95833337306976,2.875,0],"i":{"y":0.833,"x":0.833}},{"t":57.599609375}],"a":1}},"ddd":0,"ind":5,"sr":1,"bm":0,"st":0,"ip":0,"shapes":[{"mn":"ADBE Vector Group","ty":"gr","it":[{"mn":"ADBE Vector Shape - Rect","ty":"rc","d":1,"s":{"k":[72,72],"a":0},"r":{"k":18,"a":0},"nm":"Rectangle Path 1","p":{"k":[-36,0],"a":0}},{"mn":"ADBE Vector Graphic - Stroke","w":{"k":0,"a":0},"ty":"st","lj":1,"c":{"k":[1,1,1,1],"a":0},"o":{"k":100,"a":0},"lc":1,"ml":4,"nm":"Stroke 1"},{"mn":"ADBE Vector Graphic - Fill","ty":"fl","o":{"k":100,"a":0},"c":{"k":[1,0.73,0.16,1],"a":0},"nm":"Fill 1"},{"ty":"tr","sk":{"k":0,"ix":4,"a":0},"s":{"k":[23.688,6.441],"ix":3,"a":0},"r":{"k":0,"ix":6,"a":0},"sa":{"k":0,"ix":5,"a":0},"a":{"k":[0,0],"ix":1,"a":0},"p":{"k":[0,0],"ix":2,"a":0},"o":{"k":100,"ix":7,"a":0},"nm":"Transform"}],"np":3,"nm":"Rectangle 1"}],"nm":"Shape Layer 3"},{"ty":4,"op":1800,"ao":0,"ks":{"o":{"k":[{"n":["0p833_0p833_0p167_0p167"],"o":{"y":[0.167],"x":[0.167]},"e":[100],"t":14.4,"s":[0],"i":{"y":[0.833],"x":[0.833]}},{"t":31.19921875}],"a":1},"s":{"k":[{"n":["0p833_0p833_0p167_0p167","0p833_0p833_0p167_0p167","0p833_0p833_0p167_0p167"],"o":{"y":[0.167,0.167,0.167],"x":[0.167,0.167,0.167]},"e":[124,124,100],"t":14.4,"s":[40,40,100],"i":{"y":[0.833,0.833,0.833],"x":[0.833,0.833,0.833]}},{"n":["0p833_0p833_0p167_0p167","0p833_0p833_0p167_0p167","0p833_0p833_0p167_0p167"],"o":{"y":[0.167,0.167,0.167],"x":[0.167,0.167,0.167]},"e":[51,51,100],"t":31,"s":[124,124,100],"i":{"y":[0.833,0.833,0.833],"x":[0.833,0.833,0.833]}},{"t":52}],"a":1},"r":{"k":0,"a":0},"a":{"k":[0,0,0],"a":0},"p":{"k":[36,38,0],"a":0}},"ddd":0,"ind":6,"sr":1,"bm":0,"st":0,"ip":0,"shapes":[{"mn":"ADBE Vector Group","ty":"gr","it":[{"mn":"ADBE Vector Shape - Ellipse","ty":"el","d":1,"s":{"k":[72,72],"a":0},"nm":"Ellipse Path 1","p":{"k":[0,0],"a":0}},{"mn":"ADBE Vector Graphic - Stroke","w":{"k":0,"a":0},"ty":"st","lj":1,"c":{"k":[1,1,1,1],"a":0},"o":{"k":100,"a":0},"lc":1,"ml":4,"nm":"Stroke 1"},{"mn":"ADBE Vector Graphic - Fill","ty":"fl","o":{"k":100,"a":0},"c":{"k":[1,0.91,0.63,1],"a":0},"nm":"Fill 1"},{"ty":"tr","sk":{"k":0,"ix":4,"a":0},"s":{"k":[61.168,61.168],"ix":3,"a":0},"r":{"k":0,"ix":6,"a":0},"sa":{"k":0,"ix":5,"a":0},"a":{"k":[0,0],"ix":1,"a":0},"p":{"k":[0,0],"ix":2,"a":0},"o":{"k":100,"ix":7,"a":0},"nm":"Transform"}],"np":3,"nm":"Ellipse 1"}],"nm":"yuan"}],"fr":60,"h":72,"ip":0}

todo-fixme commented 5 years ago

@chenjianping99 try json as String,not JSONObject

gpeal commented 5 years ago

@bodymovin, this json file has width before type for the shape strokes. Lottie Android needs the type to be first since it uses a streaming json parser. Is it possible for bodymovin to emit this or was this json modified?

bodymovin commented 5 years ago

@gpeal I can't identify it, but version of the json is pretty old: "v":"4.5.7"
Any idea where it comes from?
v 4.5.7 was released on Feb 16, 2017

gpeal commented 5 years ago

@chenjianping99 ^