Hi guys, in latest Lottie Android version (2.5.0) we are having several crashes at doInBackground() method. This crash is only happening on Android 7 and 8 versions.
Here is our animation preloading code:
class LottieAnimations {
companion object {
@JvmStatic
var willyWaiting: LottieAnimation? = null
var specialBonusCollectCoins: LottieAnimation? = null
var specialBonusCollectGems: LottieAnimation? = null
@JvmStatic
fun load(context: Context) {
fromAssetFileName(context, "animation/waiting_lottie/data.json") {
it?.let { willyWaiting = LottieAnimation(it, "animation/waiting_lottie/images") }
}
fromAssetFileName(context, "animation/special_bonus_collect_coins/data.json") {
it?.let { specialBonusCollectCoins = LottieAnimation(it, "animation/special_bonus_collect_coins/images") }
}
fromAssetFileName(context, "animation/special_bonus_collect_gems/data.json") {
it?.let { specialBonusCollectGems = LottieAnimation(it, "animation/special_bonus_collect_gems/images") }
}
}
}
}
Here is the StackTrace:
OS Version: 8.0.0
Device: Xperia X
RAM Free: 38.5%
Disk Free: 60.8%0. Crashed: AsyncTask #4
at android.os.AsyncTask$3.done(AsyncTask.java:353) at java.#util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)--
Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:353)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)Caused by java.lang.AssertionError
at android.util.JsonReader.peek(JsonReader.java:363)
at android.util.JsonReader.expect(JsonReader.java:308)
at android.util.JsonReader.beginObject(JsonReader.java:293)
at com.airbnb.lottie.parser.LottieCompositionParser.parse(SourceFile:42)
at com.airbnb.lottie.LottieComposition$Factory.fromJsonSync(SourceFile:269)
at com.airbnb.lottie.parser.AsyncCompositionLoader.doInBackground(SourceFile:22)
at com.airbnb.lottie.parser.AsyncCompositionLoader.doInBackground(SourceFile:12)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)0. Crashed: AsyncTask #4
at android.os.AsyncTask$3.done(AsyncTask.java:353) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)1. pool-2-thread-1
at java.lang.Object.wait(Object.java) at java.lang.Thread.parkFor$(Thread.java:2135) at sun.misc.Unsafe.park(Unsafe.java:358) at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2101) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1132) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1087) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1147) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)2. httpThread
at android.os.MessageQueue.nativePollOnce(MessageQueue.java) at android.os.MessageQueue.next(MessageQueue.java:375) at android.os.Looper.loop(Looper.java:225) at android.os.HandlerThread.run(HandlerThread.java:65)3. ConnectivityThread
at android.os.MessageQueue.nativePollOnce(MessageQueue.java) at android.os.MessageQueue.next(MessageQueue.java:375) at android.os.Looper.loop(Looper.java:225) at android.os.HandlerThread.run(HandlerThread.java:65)4. pool-3-thread-1
at java.lang.Object.wait(Object.java) at java.lang.Thread.parkFor$(Thread.java:2135) at sun.misc.Unsafe.park(Unsafe.java:358) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:190) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2059) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1120) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1087) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1147) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)
Any ideas?
Tnx in advance
@fertwo can you attach the animation?
same error happens to me after I upgraded lottie from 2.3.0 to 2.5.0, mostly on Android 8.0 and some on Android 7.x
@fertwo @7heaven Can either of you attach a sample project that reproduces this? The animation posted above doesn't crash for me.

@fertwo why does you animation use images? It looks like they can all be shape layers. Please refer to the images documentation here.
I'm having this on Lottie 2.5.4 and Android 8.0 and 8.1. In my crash logs, I cannot reproduce.
@Frank1234 you're seeing it in production logs? Can you paste the exact stack?
Yes, in production logs. Here are the details:
Fatal Exception: java.lang.RuntimeException
An error occurred while executing doInBackground()
android.os.AsyncTask$3.done (AsyncTask.java:353)
java.util.concurrent.FutureTask.finishCompletion (FutureTask.java:383)
java.util.concurrent.FutureTask.setException (FutureTask.java:252)
java.util.concurrent.FutureTask.run (FutureTask.java:271)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636)
java.lang.Thread.run (Thread.java:764)
Caused by java.lang.AssertionError
android.util.JsonReader.peek (JsonReader.java:363)
android.util.JsonReader.expect (JsonReader.java:308)
android.util.JsonReader.beginObject (JsonReader.java:293)
arrow_right
com.airbnb.lottie.parser.LottieCompositionParser.parse (LottieCompositionParser.java:42)
com.airbnb.lottie.LottieComposition$Factory.fromJsonSync (LottieComposition.java:276)
com.airbnb.lottie.parser.AsyncCompositionLoader.doInBackground (AsyncCompositionLoader.java:22)
com.airbnb.lottie.parser.AsyncCompositionLoader.doInBackground (AsyncCompositionLoader.java:12)
android.os.AsyncTask$2.call (AsyncTask.java:333)
java.util.concurrent.FutureTask.run (FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636)
java.lang.Thread.run (Thread.java:764)
Device
Brand: samsung
Model: SM-A520F
Orientation: Portrait
RAM free: 203.76 MB
Disk free: 4.89 GB
plat_android Operating System
Version: 8.0.0
Orientation: Portrait
Rooted: No
bug_report Crash
Date: May 10, 2018, 9:36:00 AM
App version: 4.1.0 (2023180)
I'm seeing the same crash bug occur in Crashlytics/Firebase for our app in prod. Unfortunately I've been unable to reproduce the issue so far with any of my test devices.
My stacktrace is similar to the ones posted above:
-------
# Date: 2018-05-05T05:56:00Z
# OS Version: 8.1.0
# Device: Nexus 6P
# RAM Free: 100%
# Disk Free: 100%
# Date: 2018-05-06T15:21:00Z
# OS Version: 8.0.0
# Device: SM-G955U
# RAM Free: 40.7%
# Disk Free: 49.5%
Stacktrace from Crashlytics:
----------------------------
#0. Crashed: AsyncTask #4
at android.os.AsyncTask$3.done(AsyncTask.java:353)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
--
Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:353)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Caused by java.lang.AssertionError
at android.util.JsonReader.peek(JsonReader.java:363)
at android.util.JsonReader.expect(JsonReader.java:308)
at android.util.JsonReader.beginObject(JsonReader.java:293)
at com.airbnb.lottie.parser.LottieCompositionParser.parse(LottieCompositionParser.java:42)
at com.airbnb.lottie.LottieComposition$Factory.fromJsonSync(LottieComposition.java:276)
at com.airbnb.lottie.parser.AsyncCompositionLoader.doInBackground(AsyncCompositionLoader.java:22)
at com.airbnb.lottie.parser.AsyncCompositionLoader.doInBackground(AsyncCompositionLoader.java:12)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
#0. Crashed: AsyncTask #4
at android.os.AsyncTask$3.done(AsyncTask.java:353)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
@Frank1234 @falcon4ever Are there any commonalities like specific versions of Android?
Hi, I've been experiencing this same issue... @gpeal seems to be only on 8.0.0 and 8.1.0 devices, in my case (over 25 reports, so far). I have the same stacktrace as falcon4ever, above.
@gpeal Same like Allie mentioned, I've only seen it happening on devices running 8.0.0 and 8.1.0. In my case it's just a handful of crashes, and we have like 30+% of our users running Android 8.x or newer.
So it's possible it only affects certain devices/firmwares?
@alliecurry @falcon4ever Any other patterns you can deduce from your crash logs? Samsung, etc?
@gpeal I don't see any particular thing that stands out, just those devices above.
btw, I also noticed v2.5.5 got release 3 days ago without a change log updates. Is that version including important changes?
Seems to affect a multitude of devices:

We don't use lottie-android, but see a similar crash in our app:
Fatal Exception: java.lang.AssertionError
at android.util.JsonReader.peek(JsonReader.java:363)
...
So far we only observed crashes on devices with 8.0.0 and 8.1.0. I currently assume it is a bug in JsonReader, so I opened a bug report here: https://issuetracker.google.com/issues/79920590
I've added our details and log to the JsonReader issue report.
As of #830, you can now have separate success and failure handles. Failures will now bubble up to there instead of crashing on a background thread. If this is a device specific issue/platform issue with JsonReader, your best best is to use these new APIs to retry or just drop the animation in those cases.
I'm going to close this for now unless there is more than needs to be done on the lottie side. I'll try and release 2.6.0 soon with these changes.
I got the same problem on 7.X and 8.X with Lottie 2.5.1. So sad that Google said that they will not fix this because no one can reproduce this bug steadily.
We are having the same issues (Lottie 2.5.5) - only Android 8. So hope to find a fix soon.
Caused by java.lang.AssertionError
at android.util.JsonReader.peek(JsonReader.java:363)
at android.util.JsonReader.expect(JsonReader.java:308)
at android.util.JsonReader.beginObject(JsonReader.java:293)
at com.airbnb.lottie.parser.LottieCompositionParser.parse(LottieCompositionParser.java:42)
at com.airbnb.lottie.LottieComposition$Factory.fromJsonSync(LottieComposition.java:276)
at com.airbnb.lottie.parser.AsyncCompositionLoader.doInBackground(AsyncCompositionLoader.java:22)
at com.airbnb.lottie.parser.AsyncCompositionLoader.doInBackground(AsyncCompositionLoader.java:12)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
I'm aware this is probably an Android issue (not Lottie) but perhaps you could add an option of wrapping this in a try-catch block or something so not the whole app crashes when this happens?!
I'm seeing the same issue on 8.0.0 / 8.1.0 with Lottie 2.6.0-beta19 / 2.7.0.
java.lang.AssertionError
com.airbnb.lottie.LottieAnimationView$2.onResult(Unknown Source:5)
1 java.lang.IllegalStateException:Unable to parse composition
2 com.airbnb.lottie.LottieAnimationView$2.onResult(Unknown Source:5)
3 ......
4 Caused by:
5 java.lang.AssertionError:
6 android.util.JsonReader.peek(JsonReader.java:363)
7 android.util.JsonReader.expect(JsonReader.java:308)
8 android.util.JsonReader.beginObject(JsonReader.java:293)
9 com.airbnb.lottie.parser.LottieCompositionParser.parse(Unknown Source:47)
10 com.airbnb.lottie.LottieCompositionFactory.fromJsonReaderSync(Unknown Source:0)
11 com.airbnb.lottie.LottieCompositionFactory.fromJsonInputStreamSync(Unknown Source:10)
12 com.airbnb.lottie.LottieCompositionFactory.fromJsonInputStreamSync(Unknown Source:1)
13 com.airbnb.lottie.LottieCompositionFactory.fromAssetSync(Unknown Source:55)
14 com.airbnb.lottie.LottieCompositionFactory$1.call(Unknown Source:4)
15 com.airbnb.lottie.LottieCompositionFactory$1.call(Unknown Source:0)
16 java.util.concurrent.FutureTask.run(FutureTask.java:266)
17 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
18 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
19 java.lang.Thread.run(Thread.java:764)
@TobiasReich , I think there is no way that this can be circumvented by just catching the exception. The json is parsed for a reason, something depends on the data being parsed. If the exception is thrown you don't have the data, so you can't proceed.
In general the next steps are what was already mentioned in the ticket:
... If you are still facing this problem, please open new issue and add the relevant information along with reference to earlier issue.
I'm seeing the same issue on 8.0.0 / 8.1.0 with Lottie 2.6.0-beta19 / 2.7.0.
java.lang.AssertionError
com.airbnb.lottie.LottieAnimationView$2.onResult(Unknown Source:5)
1 java.lang.IllegalStateException:Unable to parse composition 2 com.airbnb.lottie.LottieAnimationView$2.onResult(Unknown Source:5) 3 ...... 4 Caused by: 5 java.lang.AssertionError: 6 android.util.JsonReader.peek(JsonReader.java:363) 7 android.util.JsonReader.expect(JsonReader.java:308) 8 android.util.JsonReader.beginObject(JsonReader.java:293) 9 com.airbnb.lottie.parser.LottieCompositionParser.parse(Unknown Source:47) 10 com.airbnb.lottie.LottieCompositionFactory.fromJsonReaderSync(Unknown Source:0) 11 com.airbnb.lottie.LottieCompositionFactory.fromJsonInputStreamSync(Unknown Source:10) 12 com.airbnb.lottie.LottieCompositionFactory.fromJsonInputStreamSync(Unknown Source:1) 13 com.airbnb.lottie.LottieCompositionFactory.fromAssetSync(Unknown Source:55) 14 com.airbnb.lottie.LottieCompositionFactory$1.call(Unknown Source:4) 15 com.airbnb.lottie.LottieCompositionFactory$1.call(Unknown Source:0) 16 java.util.concurrent.FutureTask.run(FutureTask.java:266) 17 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 18 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 19 java.lang.Thread.run(Thread.java:764)
兄弟你解决这个问题了吗?
i have issue to
Caused by java.lang.AssertionError
at android.util.JsonReader.peek(JsonReader.java:363)
at android.util.JsonReader.expect(JsonReader.java:308)
at android.util.JsonReader.beginObject(JsonReader.java:293)
at com.airbnb.lottie.parser.LottieCompositionParser.parse(SourceFile:42)
at com.airbnb.lottie.LottieCompositionFactory.fromJsonReaderSync(SourceFile:229)
at com.airbnb.lottie.LottieCompositionFactory.fromJsonInputStreamSync(SourceFile:163)
at com.airbnb.lottie.LottieCompositionFactory.fromJsonInputStreamSync(SourceFile:157)
at com.airbnb.lottie.LottieCompositionFactory.fromAssetSync(SourceFile:100)
at com.airbnb.lottie.LottieCompositionFactory$1.call(SourceFile:81)
at com.airbnb.lottie.LottieCompositionFactory$1.call(SourceFile:79)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
So could we please get an exception wrapping around that? I still hope this might be possible.
@rasoulmiri Please attach your animation.
I met the same problem in Android8.0.0,荣耀BND AL10,but i don't know how to fix it.
2 com.airbnb.lottie.LottieAnimationView$2.void onResult(java.lang.Throwable)(LottieAnimationView.java:68)
3 ......
4 java.lang.AssertionError:
5 android.util.JsonReader.peek(JsonReader.java:363)
6 android.util.JsonReader.expect(JsonReader.java:308)
7 android.util.JsonReader.beginObject(JsonReader.java:293)
8 com.airbnb.lottie.parser.LottieCompositionParser.com.airbnb.lottie.LottieComposition parse(android.util.JsonReader)(LottieCompositionParser.java:42)
9 com.airbnb.lottie.LottieCompositionFactory.com.airbnb.lottie.LottieResult fromJsonReaderSync(android.util.JsonReader,java.lang.String)(LottieCompositionFactory.java:229)
10 com.airbnb.lottie.LottieCompositionFactory.com.airbnb.lottie.LottieResult fromJsonInputStreamSync(java.io.InputStream,java.lang.String,boolean)(LottieCompositionFactory.java:163)
11 com.airbnb.lottie.LottieCompositionFactory.com.airbnb.lottie.LottieResult fromJsonInputStreamSync(java.io.InputStream,java.lang.String)(LottieCompositionFactory.java:157)
12 com.airbnb.lottie.LottieCompositionFactory.com.airbnb.lottie.LottieResult fromRawResSync(android.content.Context,int)(LottieCompositionFactory.java:129)
13 com.airbnb.lottie.LottieCompositionFactory$2.com.airbnb.lottie.LottieResult call()(LottieCompositionFactory.java:116)
14 com.airbnb.lottie.LottieCompositionFactory$2.java.lang.Object call()(LottieCompositionFactory.java:114)
15 java.util.concurrent.FutureTask.run(FutureTask.java:266)
16 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
17 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
18 java.lang.Thread.run(Thread.java:764)
May be it's because "context.getResources().openRawResource" cannot work correctly in background thread when starting?
Has this bug fixed?
It's not clear to my why/how this could happen inconsistently and I've never been able to repro it. I'll take a look at it but if anybody has some time to investigate, that would be great.
@gpeal having the same problem using lottie 2.7.0, but as many said I cannot reproduce it. Crashlytics reports shows that is happening in a variety of manufacturers and android 7.1.2 and 8.x. Unfortunately, I don't have time to investigate this. Let me know if I can provide any useful info
i met the same problem using lottie 2.5.1,on 魅族M5 Note
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:318)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.AssertionError
at android.util.JsonReader.peek(JsonReader.java:363)
at android.util.JsonReader.expect(JsonReader.java:308)
at android.util.JsonReader.beginObject(JsonReader.java:293)
at com.airbnb.lottie.parser.LottieCompositionParser.parse(Proguard:42)
at com.airbnb.lottie.LottieComposition$Factory.fromJsonSync(Proguard:276)
at com.airbnb.lottie.parser.AsyncCompositionLoader.doInBackground(Proguard:22)
at com.airbnb.lottie.parser.AsyncCompositionLoader.doInBackground(Proguard:12)
at android.os.AsyncTask$2.call(AsyncTask.java:304)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
... 3 more
We are having a similar problem. Crashlytics is reporting several tens of crashes (amung an audience of 300K). Haven't been able to reproduce.
Lottie v. 2.7.0
Crash demogarphics:

Lottie file:
wave_bottom_padding.json.zip
Stacktrace:
```# Crashlytics - plaintext stacktrace downloaded by Hanan - at Mon, 15 Apr 2019 09:52:19 GMT
at com.airbnb.lottie.LottieAnimationView$2.onResult(LottieAnimationView.java:68)
at com.airbnb.lottie.LottieAnimationView$2.onResult(LottieAnimationView.java:66)
at com.airbnb.lottie.LottieTask.notifyFailureListeners(LottieTask.java:167)
at com.airbnb.lottie.LottieTask.access$000(LottieTask.java:26)
at com.airbnb.lottie.LottieTask$1.run(LottieTask.java:142)
at android.os.Handler.handleCallback(Handler.java:794)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6635)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
--
Fatal Exception: java.lang.IllegalStateException: Unable to parse composition
at com.airbnb.lottie.LottieAnimationView$2.onResult(LottieAnimationView.java:68)
at com.airbnb.lottie.LottieAnimationView$2.onResult(LottieAnimationView.java:66)
at com.airbnb.lottie.LottieTask.notifyFailureListeners(LottieTask.java:167)
at com.airbnb.lottie.LottieTask.access$000(LottieTask.java:26)
at com.airbnb.lottie.LottieTask$1.run(LottieTask.java:142)
at android.os.Handler.handleCallback(Handler.java:794)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6635)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by java.util.concurrent.ExecutionException: java.lang.AssertionError
at java.util.concurrent.FutureTask.report(FutureTask.java:123)
at java.util.concurrent.FutureTask.get(FutureTask.java:193)
at com.airbnb.lottie.LottieTask$2.run(LottieTask.java:189)
Caused by java.lang.AssertionError
at android.util.JsonReader.peek(JsonReader.java:363)
at android.util.JsonReader.expect(JsonReader.java:308)
at android.util.JsonReader.beginObject(JsonReader.java:293)
at com.airbnb.lottie.parser.LottieCompositionParser.parse(LottieCompositionParser.java:42)
at com.airbnb.lottie.LottieCompositionFactory.fromJsonReaderSync(LottieCompositionFactory.java:229)
at com.airbnb.lottie.LottieCompositionFactory.fromJsonInputStreamSync(LottieCompositionFactory.java:163)
at com.airbnb.lottie.LottieCompositionFactory.fromJsonInputStreamSync(LottieCompositionFactory.java:157)
at com.airbnb.lottie.LottieCompositionFactory.fromRawResSync(LottieCompositionFactory.java:129)
at com.airbnb.lottie.LottieCompositionFactory$2.call(LottieCompositionFactory.java:116)
at com.airbnb.lottie.LottieCompositionFactory$2.call(LottieCompositionFactory.java:114)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
...
```
lottie_crash_stacktrace.txt
Just encountered this too after updating animation. It worked with first one but fails with new one, main difference is the size 8kb (is ok) vs 17kb (exception)
I know that this is a weird question but have you putted the json in assets folder and set the build action to androidasset? I had the same error and fixed it by setting the build action to androidasset.
Thnx
On which version of Lottie was this fixed?
I had this on 3.0.3 , in this form:
Sadly I can't update to 3.0.6 or even 3.0.4 , because it doesn't support this:
https://github.com/airbnb/lottie-android/issues/1270
@mohamed-azikiou that resolved my issue as well, moved json file to assets folder, set build action to androidasset - issue resolved.
@AndroidDeveloperLB The JsonReader change that you're encountering is the fix for this bug.
@gpeal I see. Are there any other known crashes on latest versions of the library though?
@AndroidDeveloperLB No known crashes in 3.0.7
@gpeal I see. Thank you. I hope a new version will come out soon.
Also pops up with com.github.wwdablu:lottiebottomnav:1.0.0
I'm using lottie:3.0.7
I had to set dataBinding { enabled = true } otherwise it rises another error regarding Landroidx/databinding/DataBinderMapperImpl;
Also reported on github.wwdablu
Also pops up with
com.github.wwdablu:lottiebottomnav:1.0.0
I'm usinglottie:3.0.7
I had to setdataBinding { enabled = true }otherwise it rises another error regardingLandroidx/databinding/DataBinderMapperImpl;Also reported on github.wwdablu
It works if you put the lottie animation inside the assets folder (it crashes if inside the raw folder)
And dataBinding { enabled = true } needs to be set in the gradle file otherwise you'll end up with Landroidx/databinding/DataBinderMapperImpl; error
_If someone is interested in using lottie animations with_ com.github.wwdablu:lottiebottomnav:1.0.0 _don't forget to declare the source to be_ MenuItem.Source.Assets _and not_ MenuItem.Source.Raw
androidasset
Can you tell me where to set the build action? I didn't find anywhere to set. Thanks a lot.
@1wayticket , what do you mean by build action?
The .json file needs to go in app>src>main>assets
androidasset
Can you tell me where to set the build action? I didn't find anywhere to set. Thanks a lot.
@1wayticket , what do you mean by build action?
The .json file needs to go in app>src>main>assets
Sorry,I want to ask someone else about multi lottie. So my comment is not about you,Sorry for disturb.
I know that this is a weird question but have you putted the json in assets folder and set the build action to androidasset? I had the same error and fixed it by setting the build action to androidasset.
Thnx
I have the same question with you ,So can you share about your solution -- set the build action to androidasset. I'm confused about how to set it? or can you leave your WeChat or Email?
Sadly updating to 3.0.7 causes a different issue:
https://github.com/airbnb/lottie-android/issues/1298
Is there a version that doesn't have both of those issues?
Is it true that putting the Lottie files (the json files) into assets folder will fix it?
Sadly updating to 3.0.7 causes a different issue:
1298
Is there a version that doesn't have both of those issues?
Is it true that putting the Lottie files (the json files) into assets folder will fix it?
@AndroidDeveloperLB, this has fixed mine at least! I guess it doesn't change much to put them in /raw or /assets, you just need to remember setup the correct one in the code. (It might change something in term of performances though but I haven't checked)
@Cdik I had this issue with the most basic usage of Lottie, in 2 animationViews .
In both of them, we have in layout XML file app:lottie_rawRes="@raw/... .
So instead of this, I called in code animationView.setAnimation("...json").
Do you think it's similar to what you did?
Do you use 3.0.3 now, or 3.0.7 ? The 3.0.7 version causes a different serious issue for us, so I need to choose if I want to deal with this issue or the other :(
@Cdik I've tested it. It might help a lot, but not in 100% of the times. Written about it here:
https://github.com/airbnb/lottie-android/issues/1298#issuecomment-512686118
I am using 3.0.7 version and it crashes for with same error when i do setAnimation() programatically with custom view.
In my custom view and i am getting the json file name from custom view attribute and setting it in setAnimation() like below.
val courseCardAnimJson = typedArray.getString(R.styleable.PickCourseItem_courseCardAnimJson)
courseAnimImage.setAnimation(courseCardAnimJson)
But if i pass the file name directly to the setAnimation() as below it works fine.
courseAnimImage.setAnimation("basic_course.json")
For me it happen when I misspelled my Lottie file name. After referring to correct file this error was gone.

Most helpful comment
We are having the same issues (Lottie 2.5.5) - only Android 8. So hope to find a fix soon.
I'm aware this is probably an Android issue (not Lottie) but perhaps you could add an option of wrapping this in a try-catch block or something so not the whole app crashes when this happens?!