Solvedlottie android JSON Reader AssertionError when doInBackground (Android 7, 8)

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

52 Answers

βœ”οΈAccepted Answer

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?!

Other Answers:

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

Related Issues:

12
lottie android JSON Reader AssertionError when doInBackground (Android 7, 8)
We are having the same issues (Lottie 2.5.5) - only Android 8 So hope to find a fix soon ...
316
lottie react native Could not find com.android.support:appcompat-v7:26.1.0.
you are right there is also something else your other build.gradle file add maven url 'https://maven...
121
lottie react native 'Lottie/Lottie.h' file not found on release builds
@dejakob Go to General > Embedded Binaries > add Lottie.framework Dear I added lottie-react-native i...
102
lottie react native iOS doesn't build latest version 3.0.3
I've solved this issue If you're using ios/{projectName}.xcodeproj with XCode to build your project ...
31
lottie react native Error in Latest versions (3.1.8)
That's what worked for me. Description [!] CocoaPods could not find compatible versions for pod lott...
29
lottie react native Linking lottie-ios crashes on iOS
@rodrigoelp I've got it compiling in Xcode 10 (RN 0.57) by linking everything manually: Remove lotti...
24
lottie react native Build failed after update
In app/build.gradle add this πŸ‘ Works fine After update to 2.5.0 version (from 2.3.2) build is faili...
22
lottie react native Execution failed for task ':lottie-react-native:compileDebugJavaWithJavac'.
Migrating to Android X Fixed it for me i.e: Adding to my gradle.properties and running Jetifier ...
17
lottie react native Cannot build on React Native 0.41.2
I got it working by adding Lottie.framework to Embedded Binaries in XCode. Current behavior: Cannot ...
12
lottie react native 2.3.0 Animations no longer appear (upgrading from 1.2 to 2.3)
I ran into this problem as well after upgrading from version 2.2.7 to 2.3.1 all my animations in iOS...
11
lottie react native remote uri
Hi Again We have fixed the problem with this approach : and the component : I tried using along the ...
11
lottie react native Create androidx support
This comes down to updating the dependencies to a version of lottie-android of at least 2.8.0 ...
10
lottie react native Crashing on Android: TypeError: expected dynamic type `int64', but had type `double'
I had the same issue but managed to fix it by manually changing the fr value to an int inside the JS...
7
lottie react native Animations that use images don't work.
I figure out this issue for android created assets folder in Android I'm currently using easy-lottie...
5
nexrender Is it able to bridge AME to render?
AME is still a good alternative to AERender especially with its multiprocessing/multicore rendering ...
3
nexrender Injecting scripts does not work in AE 2018
Hi I identified the problem with ae 2018 it doesn't save the $.evalfile in binary format instead it ...
750
react native keychain SDK Build Tools revision (23.0.1) is too low for project :react-native-keychain.
Ok I found a solution to this For people facing the same problem in the future Hey there ...
748
material components android Manifest merger failed : Attribute application@appComponentFactory
I had similar problem We're transitioning from github issues to a public buganizer component Rather ...
746
expo Error: fsevents unavailable (this watcher can only be used on Darwin)
Possible solution: I had installed watchman via npm install -g watchman but apparently this installs...
459
flutter Multiple commands produce '/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework
I was able to fix it by opening the Runner workspace project in Xcode 10 Then navigate to File ...
449
flutter App Store iOS submission fails: The bundle Runner.app/Frameworks/App.framework does not support the minimum OS Version specified in the Info.plist
After doing a flutter clean changing MinimumOSVersion (inside /ios/Flutter/AppframeworkInfo.plist) t...
418
flutter 'com.android.support:appcompat-v7' has different version for the compile (26.1.0) and runtime (27.0.1) classpath
is like this i receive an error when i run flutter run My gradle.build file is: flutter doctor: ...
409
flutter Why does my text not wrap?
You have to wrap Column in a flexible Without flexible the column's width is not constrained to the ...
383
flutter Unexpected top padding in ListView put inside scaffold with no appBar
Yeah this is intentional If you put a widget before the ListView you should wrap the ListView with a...
315
flutter Missing xcode dependency: Python module "six"
try python2.x -m pip install six by @humblerookie's suggest or brew reinstall python@2 pip install s...
306
expo exp build:android fails
This works exp start Cancel ctrl c then do exp build:android. Running exp build:android errors fails...
285
flutter flutter messaging: set the notification icon
Hey guys I fought with this for the better part of a day For some strange reason there are no tutori...
281
flutter Issue with cloud_firestore - Cannot fit requested classes in a single dex file.
As a workaround you can try enabling mutlidex for Android App by following Enable multidex for apps ...
265
flutter D8: Program type already present: io.flutter.BuildConfig
@smrucv I received the same error but after flutter clean and flutter packages get everything works ...
250
238
flutter Introduction of characters package causes crash on flutter run for preexisting Flutter applications
In my case I resolved the issue with flutter clean After e0ed12c I get this error when building: @ju...
222
nativescript cli TNS doctor doesn't recognize Xcode (High Sierra)
HI @philipfeldmann Can yhou please run xcodebuild -version and paste the output? May be Xcode is ins...
221
flutter Making Network http error SocketException: Failed host lookup
@hoc081098 Double-check / make sure you have <uses-permission android:name=android.permission.INTERN...
216
flutter Support inlining Android/iOS views
iOS view embedding support has landed on master This is still just a preview There are multiple open...
207
flutter βœ— Android license status unknown.
Hi everyone Steps to Reproduce Please tell us what you were doing and what went wrong If you are run...
195
react native mapbox gl No static method toHumanReadableAscii
here is workaround: build.gradle got the following error on runtime: java.lang.NoSuchMethodError: No...
185
flutter idevice_id cannot run on catalina
When you're developing on Catalina Steps to Reproduce Run flutter doctor on macOS Catalina I get the...
181
flutter type 'List<dynamic>' is not a subtype of type 'List<String>'
The problem is your fromMap constructor is reading from a Map<String dynamic> ...
178
flutter TextField is hidden by keyboard inside of a Modal Bottom Sheet
This may not work for all situations but I have a modalBottomSheet that contains only a TextField ...
173
retrofit Kotlin & @Body
You can still use Map just suppress its wildcardness with @JvmSuppressWildcards ...
169
NativeBase Needs to tap twice to fire onPress function when keyboard is open
@bm-software Use keyboardShouldPersistTaps={'handled'} and will works fine. react-native ...
162
react native firebase πŸ”₯(Android) Program type already present: io.invertase.firebase.BuildConfig
I think I found my ultimate error here In my package.json file I had at some point earlier ...
160
flutter Dismissing keyboard programatically
This is a better way as it also clears the focus: FocusScope.of(context).requestFocus(new FocusNode(...
157
flutter How to solve: Android license status unknown and also Android sdkmanager tool not found? Tried everything(as i think)
The answer is here Uncheck Hide Obsolete Packages and you'll see Android SDK Tools (Obsolete) 26.1.1...
156
flutter MissingPluginException: No implementation found for method
@mravn-google Yeah turned out I had to quit the flutter run process and start it up again Just a ful...
156
flutter firebase_auth: ^0.8.0+1 crashes on Android
Here i put this in file: android/gradle.properties: and changed targetSdkVersion to 28 and it worked...
156
react native modal The statusbar turns white when the modal is open (only on certain devices)
statusBarTranslucent property has been added to Modal of RN 0.62 I think this problem has been solve...