software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.9k stars 1.3k forks source link

[V3][Android]: App crashes when running with expo run:android on expo 49, but it works with eas build #5231

Open nickrugge opened 12 months ago

nickrugge commented 12 months ago

Description

Building a development build with expo prebuild and running importing Animated from 'react-native-reanimated' produces the error: Exception in HostFunction: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreanimated.so

If i produce the development build (developmentClient:true) on eas with npx eas-cli build -p android --profile development and run the build attaching the metro bundler it works correctly.

Steps to reproduce

  1. create a new expo 49 project npx create-expo-app --template i choose "Blank (Typescript)"
  2. install react-native-reanimated following the steps from the doc
  3. run npx expo prebuild --clean
  4. run npx expo run:android
  5. Import the reanimated module
import Animated from 'react-native-reanimated';

App build successfully but after importing the Animated dependency it crashes with

Error: Exception in HostFunction: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreanimated.so
        SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/test.app/lib-main flags = 1]
        SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/~~I0nMZBcjVgMEz8VPYU4zsw==/test.app-UuM5CpcsMw2Mza5acOv0nQ==/lib/arm64 flags = 0]
        SoSource 2: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2]
        SoSource 3: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2]
        Native lib dir: /data/app/~~I0nMZBcjVgMEz8VPYU4zsw==/test.app-UuM5CpcsMw2Mza5acOv0nQ==/lib/arm64
 result: 0, js engine: hermes 
    at ContextNavigator (http://192.168.1.5:8081/index.ts.bundle//&platform=android&dev=true&minify=false&app=test.app&modulesOnly=false&runModule=true:152600:24)
    at ExpoRoot (http://192.168.1.5:8081/index.ts.bundle//&platform=android&dev=true&minify=false&app=test.app&modulesOnly=false&runModule=true:152571:30)
    at App
    at withDevTools(App) (http://192.168.1.5:8081/index.ts.bundle//&platform=android&dev=true&minify=false&app=test.app&modulesOnly=false&runModule=true:130960:27)
    at ErrorToastContainer (http://192.168.1.5:8081/index.ts.bundle//&platform=android&dev=true&minify=false&app=test.app&modulesOnly=false&runModule=true:130861:24)
    at ErrorOverlay
    at RCTView
    at View (http://192.168.1.5:8081/index.ts.bundle//&platform=android&dev=true&minify=false&app=test.app&modulesOnly=false&runModule=true:40266:43)
    at RCTView
    at View (http://192.168.1.5:8081/index.ts.bundle//&platform=android&dev=true&minify=false&app=test.app&modulesOnly=false&runModule=true:40266:43)
    at AppContainer (http://192.168.1.5:8081/index.ts.bundle//&platform=android&dev=true&minify=false&app=test.app&modulesOnly=false&runModule=true:40106:36)
    at main(RootComponent) (http://192.168.1.5:8081/index.ts.bundle//&platform=android&dev=true&minify=false&app=test.app&modulesOnly=false&runModule=true:121428:28)

Snack or a link to a repository

https://github.com/nickrugge/reanimated-crash-repro

Reanimated version

3.3.0

React Native version

0.72.5

Platforms

Android

JavaScript runtime

Hermes

Workflow

Expo Dev Client

Architecture

None

Build type

None

Device

Real device

Device model

No response

Acknowledgements

Yes

Latropos commented 10 months ago

Hi! I've run your example and I've created a brand new one with your provided commands. Everything works for me and I still have no idea why it doesn't work for you šŸ˜¢ I've checked that your plugin config is valid. You can try removing you node_modules and downloading it again.

sb0210 commented 10 months ago

This is happening for me as well. Exact same issue. Things are working with Metro but not working without metro when I am building an apk

eithe commented 10 months ago

Adding my scenario as well. This is from Google pre-launch report when I have built the app from scratch in production mode (so no Metro + clean node_modules since I build on AppCenter). I can see that for me it's x86_64 and not arm64 it crashes for.

Exception com.facebook.react.common.JavascriptException: Error: Exception in HostFunction: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreanimated.so
    SoSource 0: com.facebook.soloader.DirectorySoSource[root = /data/app/~~foo==/com.my.app-bar==/lib/x86_64 flags = 0]
    SoSource 1: com.facebook.soloader.DirectApkSoSource[root = [/data/app/~~foo==/com.my.app-bar==/base.apk!/lib/x86_64, /data/app/~~foo==/com.my.app-bar==/split_config.da.apk!/lib/x86_64, /data/app/~~foo==/com.my.app-bar==/split_config.x86_64.apk!/lib/x86_64, /data/app/~~foo==/com.my.app-bar==/split_config.xxhdpi.apk!/lib/x86_64]]
    SoSource 2: com.facebook.soloader.DirectApkSoSource[root = [/data/app/~~foo==/com.my.app-bar==/split_config.xxhdpi.apk!/lib/x86_64]]
    SoSource 3: com.facebook.soloader.DirectApkSoSource[root = [/data/app/~~foo==/com.my.app-bar==/split_config.x86_64.apk!/lib/x86_64]]
    SoSource 4: com.facebook.soloader.DirectApkSoSource[root = [/data/app/~~foo==/com.my.app-bar==/split_config.da.apk!/lib/x86_64]]
    SoSource 5: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2]
    SoSource 6: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2]
    Native lib dir: /data/app/~~foo==/com.my.app-bar==/lib/x86_64
 result: 0, js engine: hermes, stack:
callNativeSyncHook@1:120879
nonPromiseMethodWrapper@1:118142
NativeReanimated@1:730105
anonymous@1:721780
loadModuleImplementation@1:89132
guardedLoadModule@1:88687
metroRequire@1:88315
anonymous@1:720852
loadModuleImplementation@1:89132
guardedLoadModule@1:88687
metroRequire@1:88315
anonymous@1:712865
loadModuleImplementation@1:89132
guardedLoadModule@1:88687
metroRequire@1:88315
anonymous@1:711095
loadModuleImplementation@1:89132
guardedLoadModule@1:88687
metroRequire@1:88315
anonymous@1:710016
loadModuleImplementation@1:89132
guardedLoadModule@1:88687
metroRequire@1:88315
anonymous@1:2328441
loadModuleImplementation@1:89132
guardedLoadModule@1:88687
metroRequire@1:88315
anonymous@1:2327282
loadModuleImplementation@1:89132
guardedLoadModule@1:88687
metroRequire@1:88315
anonymous@1:2326274
loadModuleImplementation@1:89132
guardedLoadModule@1:88687
metroRequire@1:88315
anonymous@1:955527
loadModuleImplementation@1:89132
guardedLoadModule@1:88687
metroRequire@1:88315
anonymous@1:954497
loadModuleImplementation@1:89132
guardedLoadModule@1:88687
metroRequire@1:88315
anonymous@1:952508
loadModuleImplementation@1:89132
guardedLoadModule@1:88687
metroRequire@1:88315
anonymous@1:95506
loadModuleImplementation@1:89132
guardedLoadModule@1:88644
metroRequire@1:88315
global@1:87871
  at com.facebook.react.modules.core.ExceptionsManagerModule.reportException (ExceptionsManagerModule.java:65)
  at java.lang.reflect.Method.invoke
  at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:372)
  at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:188)
  at com.facebook.jni.NativeRunnable.run
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:27)
  at android.os.Looper.loopOnce (Looper.java:201)
  at android.os.Looper.loop (Looper.java:288)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:228)
  at java.lang.Thread.run (Thread.java:920)

Trying to replicate locally, but haven't been successful so far. Maybe it's because it looks to only be an issue on x86_64 for me.

Edit: We don't need to support x86_64 for our app so I have just disabled building for that. We actually had it disabled previously, but the abiFilters where lost when we upgraded React Native.

TimoVie commented 7 months ago

Same issue on m1 pro. Trying to run on android simulator and getting the same error.

eithe commented 7 months ago

Same issue on m1 pro. Trying to run on android simulator and getting the same error.

I would not recommend running x86_64 emulators when you have a Apple silicon mac, use arm64 instead, it will be a lot faster, and you won't have this issue.

TimoVie commented 7 months ago

Same issue on m1 pro. Trying to run on android simulator and getting the same error.

I would not recommend running x86_64 emulators when you have a Apple silicon mac, use arm64 instead, it will be a lot faster, and you won't have this issue.

I'm running an arm64 simulator (Android 13.0 Tiramisu, Pixel 7 Pro) and still have this issue :(

eithe commented 7 months ago

I'm running an arm64 simulator (Android 13.0 Tiramisu, Pixel 7 Pro) and still have this issue :(

So what is your exception message, then?

TimoVie commented 7 months ago

So what is your exception message, then?

Error: Exception in HostFunction: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreanimated.so
        SoSource 0: com.facebook.soloader.DirectorySoSource[root =/data/app/~~voF3aBF6aAsBZqzlJPKeBQ==/lib/arm64 flags = 0]
        SoSource 1: com.facebook.soloader.DirectApkSoSource[root = [/data/app/~~voF3aBF6aAsBZqzlJPKeBQ==/base.apk!/lib/arm64-v8a]]
        SoSource 2: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2]
        SoSource 3: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2]
        Native lib dir: /data/app/~~voF3aBF6aAsBZqzlJPKeBQ==/iecd8-IoLYETbq4UtGeiNw==/lib/arm64
 result: 0, js engine: hermes 
    at ContextNavigator (http://10.0.2.2:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&lazy=true&minify=false&app=&modulesOnly=false&runModule=true&transform.routerRoot=app&transform.engine=hermes:153231:24)
    at ExpoRoot (http://10.0.2.2:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&lazy=true&minify=false&app=&modulesOnly=false&runModule=true&transform.routerRoot=app&transform.engine=hermes:153187:28)
    at App
    at ErrorToastContainer (http://10.0.2.2:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&lazy=true&minify=false&app=&modulesOnly=false&runModule=true&transform.routerRoot=app&transform.engine=hermes:253794:24)
    at ErrorOverlay
    at withDevTools(ErrorOverlay) (http://10.0.2.2:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&lazy=true&minify=false&app=&modulesOnly=false&runModule=true&transform.routerRoot=app&transform.engine=hermes:253544:27)
    at RCTView
    at View (http://10.0.2.2:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&lazy=true&minify=false&app=&modulesOnly=false&runModule=true&transform.routerRoot=app&transform.engine=hermes:40275:43)
    at RCTView
    at View (http://10.0.2.2:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&lazy=true&minify=false&app=&modulesOnly=false&runModule=true&transform.routerRoot=app&transform.engine=hermes:40275:43)
    at AppContainer (http://10.0.2.2:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&lazy=true&minify=false&app=&modulesOnly=false&runModule=true&transform.routerRoot=app&transform.engine=hermes:40086:36)
    at main(RootComponent) (http://10.0.2.2:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&lazy=true&minify=false&app=&modulesOnly=false&runModule=true&transform.routerRoot=app&transform.engine=hermes:124483:28)