I have an android application built on React Native. It has worked fine through multiple updates over the past few months, but out of nowhere I started getting this error when building it. The app will not start up at all.
FATAL EXCEPTION: main
Process: com.appname.appname, PID: 30423
java.lang.NoSuchMethodError: No interface method removeLast()Ljava/lang/Object; in class Ljava/util/List; or its super classes (declaration of 'java.util.List' appears in /apex/com.android.art/javalib/core-oj.jar)
at com.swmansion.rnscreens.ScreenStack.obtainDrawingOp(ScreenStack.kt:319)
at com.swmansion.rnscreens.ScreenStack.drawChild(ScreenStack.kt:303)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4317)
at com.swmansion.rnscreens.ScreenStack.dispatchDraw(ScreenStack.kt:288)
at android.view.View.updateDisplayListIfDirty(View.java:22747)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4540)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4513)
at android.view.View.updateDisplayListIfDirty(View.java:22712)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4540)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4513)
at android.view.View.updateDisplayListIfDirty(View.java:22712)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4540)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4513)
at android.view.View.updateDisplayListIfDirty(View.java:22712)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4540)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4513)
at android.view.View.updateDisplayListIfDirty(View.java:22712)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4540)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4513)
at android.view.View.updateDisplayListIfDirty(View.java:22712)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4540)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4513)
at android.view.View.updateDisplayListIfDirty(View.java:22712)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4540)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4513)
at android.view.View.updateDisplayListIfDirty(View.java:22712)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4540)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4513)
at android.view.View.updateDisplayListIfDirty(View.java:22712)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRender
er.java:694)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:700)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:798)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:4939)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4643)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3822)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2465)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9305
)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1339)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1348)
at android.view.Choreographer.doCallbacks(Choreographer.java:952)
at android.view.Choreographer.doFrame(Choreographer.java:882)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1322)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeIni
t.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
In my build.gradle I have the below but this has been consistent and I did not upgrade anything. I also did not update any packages as far as I can remember, although I've read that maybe this is related to react-native-screens?
I'd love some help on this. My app won't even start up. It's supposed to open to the main screen, auto log the user in and transition to the home page but it crashes before you can even see anything. It just shows this error.
buildToolsVersion = "34.0.0"
minSdkVersion = 24
compileSdkVersion = 35
targetSdkVersion = 35
ndkVersion = "26.1.10909125"
kotlinVersion = "1.8.0"
supportLibVersion = "28.0.0"
androidXAnnotation = "1.1.0"
androidXBrowser = "1.0.0"
My package.json has the following:
"dependencies": {
"@miblanchard/react-native-slider": "^2.6.0",
"@pusher/pusher-websocket-react-native": "^1.3.0",
"@react-native-async-storage/async-storage": "^1.23.1",
"@react-native-community/netinfo": "^9.5.0",
"@react-native-cookies/cookies": "^6.2.1",
"@react-native-firebase/app": "^19.2.2",
"@react-native-firebase/auth": "^19.2.2",
"@react-native-firebase/messaging": "^19.3.0",
"@react-native/metro-config": "^0.74.84",
"@react-navigation/bottom-tabs": "^6.5.20",
"@react-navigation/native": "^6.1.17",
"@react-navigation/native-stack": "^6.9.26",
"@reduxjs/toolkit": "^2.2.3",
"@rneui/themed": "^4.0.0-rc.8",
"@sharpsports/sharpsports-mobile": "2.5.0",
"@types/react-router": "^5.1.20",
"axios": "^1.6.8",
"core-js": "^3.36.1",
"firebase": "^10.11.0",
"lodash": "^4.17.21",
"react": "18.2.0",
"react-native": "0.74.2",
"react-native-chart-kit": "^6.12.0",
"react-native-collapsible": "^1.6.1",
"react-native-config": "^1.5.2",
"react-native-device-info": "^10.13.2",
"react-native-gesture-handler": "^2.17.1",
"react-native-gifted-charts": "^1.4.10",
"react-native-iap": "^12.15.0",
"react-native-linear-gradient": "^2.8.3",
"react-native-reanimated": "^3.13.0",
"react-native-safe-area-context": "4.10.1",
"react-native-screens": "3.31.1",
"react-native-svg": "^15.3.0",
"react-native-typescript-transformer": "^1.2.13",
"react-native-webview": "^13.10.3",
"react-redux": "^9.1.0",
"redux-persist": "^6.0.0",
"tailwind-rn": "^4.2.0",
"zod": "^3.22.4"
},
I figured this out. The problem was that...
compileSdkVersion = 35
targetSdkVersion = 35
was not happy with my version of react-native-screens. That library was using removeLast() under the hood, and as a result was causing problems. I updated this to the latest version (3.35.0 at the time of writing this).
Initially this did not fix the problem but I also ran cd android && ./gradlew clean and also went to Android studio and closed my emulator and ran another "clean project" from there. After all this, I rebooted and things worked. The reason upgrading react-native-screens didn't initially work was likely because I was running a cached version of my app.
Setup before issue:
"react-native": "0.73.11",
"react-native-screens": "3.28.0",
"react-native-gesture-handler": "2.14.0"
After upgrading react-native-screens to 3.33.0, the app started crashing with:
java.lang.NoSuchMethodError: No virtual method reversed()Ljava/util/List; in class Ljava/util/ArrayList;
or its super classes (declaration of 'java.util.ArrayList' appears in /apex/com.android.art/javalib/core-oj.jar)
The crash happens because reversed() is not available on ArrayList in older Android runtimes.
Some Android versions (especially lower API levels) don’t have this extension method, so the app breaks at runtime.
I patched GestureHandlerOrchestrator.kt in react-native-gesture-handler where reversed() was used.
Instead of reversed(), use asReversed() which is fully compatible.
Open:
node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt
Replace all:
.reversed()
with:
.asReversed()
Save changes.
Use patch-package so the fix persists after reinstalling node modules:
npx patch-package react-native-gesture-handler
After applying the patch, the crash was resolved and the app worked fine across devices.
Hopefully, this helps anyone who runs into the same issue after upgrading react-native-screens!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With