Thursday, February 16, 2023

dlopen failed: cannot locate symbol "__emutls_get_address" referenced by "/lib/arm64/libfolly_runtime.so"

dlopen failed: cannot locate symbol "__emutls_get_address" referenced by "/data/app/xadfadsfas==/xxxxxxx==/lib/arm64/libfolly_runtime.so"


https://github.com/facebook/react-native/blob/main/ReactAndroid/src/main/jni/third-party/folly/CMakeLists.txt

target_compile_options(folly_runtime PUBLIC ${folly_FLAGS})

target_include_directories(folly_runtime PUBLIC .)

Where, In the app. we need to check runtime libraries, 

Which will be residing under jniLibs folder.

If your application includes multiple shared libraries, you should use libc++_shared.so.

On Android, the libc++ used by the NDK is not the same as the one that's part of the OS. This gives NDK users access to the latest libc++ features and bug fixes even when targeting old versions of Android. The trade-off is that if you use libc++_shared.so, you must include it in your app. If you're building your application with Gradle this is handled automatically.

Old versions of Android had bugs in PackageManager and the dynamic linker that caused installation, update, and loading of native libraries to be unreliable. In particular, if your app targets a version of Android earlier than Android 4.3 (Android API level 18), and you use libc++_shared.so, you must load the shared library before any other library that depends on it.

libc++ is not a system library. If you use libc++_shared.so, it must be included in your app. If you're building your application with Gradle this is handled automatically.

run the command nm -gD libc++_shared.so

Where __emutls_get_address method is missing in the libc++_shared.so, Update the latest libc++_shared.so, the problem will be solved