# java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found

- **ID:** `android/unsatisfiedlinkerror-libc++-shared-not-found`
- **Domain:** android
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Android NDK r25c | active | — | — |
| Android NDK r26b | active | — | — |
| AGP 8.1.0 | active | — | — |
| AGP 8.2.2 | active | — | — |
| Gradle 8.4 | active | — | — |

## Workarounds

1. **Add `packagingOptions { pickFirst '**/libc++_shared.so' }` in app/build.gradle to ensure the library is included from all dependencies without duplicates.** (85% success)
   ```
   Add `packagingOptions { pickFirst '**/libc++_shared.so' }` in app/build.gradle to ensure the library is included from all dependencies without duplicates.
   ```
2. **Set `android.defaultConfig.ndk.abiFilters 'arm64-v8a', 'x86_64'` to limit native builds to specific ABIs and bundle the correct libc++_shared.so.** (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.
   ```

## Dead Ends

- **** — Adding android:extractNativeLibs="true" in AndroidManifest.xml may help with extraction but does not fix missing library packaging; the library must be explicitly included. (70% fail)
- **** — Manually copying libc++_shared.so into jniLibs without matching CPU architectures often leads to UnsatisfiedLinkError for unsupported ABIs. (80% fail)
- **** — Setting android.useAndroidX=true alone does not resolve native library dependencies; it only affects Java/Kotlin dependencies. (90% fail)
