Skip to content

UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_Unwind_Resume"

Description

libVLC throws a UnsatisfiedLinkError exception at runtime when I've configured the app with the shared STL like this in build.gradle.kts:

android {
    defaultConfig {
        externalNativeBuild {
            cmake {
                arguments("-DANDROID_STL=c++_shared")
            }
        }
    }
}

The full error that gets thrown when (I'm guessing) System.loadLibrary("vlcjni"); gets called looks like this:

2021-10-21 14:54:05.700 15837-15837/se.davidk.test E/VLC/LibVLC: Can't load vlcjni library: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_Unwind_Resume" referenced by "/data/app/se.davidk.test-QN6xtahycd5kIwyN5DKXFg==/base.apk!/lib/x86/libvlc.so"...
2021-10-21 14:54:05.702 15837-15837/se.davidk.test I/e.davidk.test: System.exit called, status: 1
2021-10-21 14:54:05.702 15837-15837/se.davidk.test I/AndroidRuntime: VM exiting with result code 1, cleanup skipped.

If I remove the -DANDROID_STL=c++_shared argument everything seems to be working fine. I found a similar issue in the Android oboe issue tracker on Github here: https://github.com/google/oboe/issues/966. Oboe is also the library that told me to add the c++_shared argument in their setup tutorial in the first place.

Sorry if I'm missing something obvious with this because I'm very new with C++ and the NDK. I noticed that LibVLC.java is calling System.loadLibrary("c++_shared") which might be conflicting with my DANDROID_STL=c++_shared argument somehow?

Expected behavior

I expected libVLC to not throw a UnsatisfiedLinkError when the native library is loaded.

Actual behavior

libVLC throws a UnsatisfiedLinkError when using c++_shared is added as a cmake argument.

Steps to reproduce

  1. Add -DANDROID_STL=c++_shared as a cmake argument in build.gradle.kts
  2. Add org.videolan.android:libvlc-all:3.4.4 as a gradle dependency
  3. Create an instance of a class of org.videolan.libvlc.MediaPlayer so System.loadLibrary("vlcjni") gets called. This should trigger the error I think.

App version

I've tested this with libVLC 3.4.0 and 3.4.4.

Android version

Android 10/11

Device model

x86 Emulator Samsung Galaxy S10e

Edited by David Karlsson