android
runtime_error
ai_generated
true
java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
ID: android/unsatisfiedlinkerror-libc++-shared-not-found
85%Fix Rate
88%Confidence
1Evidence
2023-06-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Android NDK r25c | active | — | — | — |
| Android NDK r26b | active | — | — | — |
| AGP 8.1.0 | active | — | — | — |
| AGP 8.2.2 | active | — | — | — |
| Gradle 8.4 | active | — | — | — |
Root Cause
App uses native code with C++ STL but the shared library libc++_shared.so is not bundled or its APK packaging is misconfigured.
generic中文
应用使用带有 C++ STL 的原生代码,但未打包共享库 libc++_shared.so 或 APK 打包配置错误。
Official Documentation
https://developer.android.com/ndk/guides/cpp-support#shared_runtimeWorkarounds
-
85% success Add `packagingOptions { pickFirst '**/libc++_shared.so' }` in app/build.gradle to ensure the library is included from all dependencies without duplicates.
Add `packagingOptions { pickFirst '**/libc++_shared.so' }` in app/build.gradle to ensure the library is included from all dependencies without duplicates. -
90% success Set `android.defaultConfig.ndk.abiFilters 'arm64-v8a', 'x86_64'` to limit native builds to specific ABIs and bundle the correct libc++_shared.so.
Set `android.defaultConfig.ndk.abiFilters 'arm64-v8a', 'x86_64'` to limit native builds to specific ABIs and bundle the correct libc++_shared.so.
中文步骤
Add `packagingOptions { pickFirst '**/libc++_shared.so' }` in app/build.gradle to ensure the library is included from all dependencies without duplicates.Set `android.defaultConfig.ndk.abiFilters 'arm64-v8a', 'x86_64'` to limit native builds to specific ABIs and bundle the correct libc++_shared.so.
Dead Ends
Common approaches that don't work:
-
70% fail
Adding android:extractNativeLibs="true" in AndroidManifest.xml may help with extraction but does not fix missing library packaging; the library must be explicitly included.
-
80% fail
Manually copying libc++_shared.so into jniLibs without matching CPU architectures often leads to UnsatisfiedLinkError for unsupported ABIs.
-
90% fail
Setting android.useAndroidX=true alone does not resolve native library dependencies; it only affects Java/Kotlin dependencies.