[FIXED] Android cash : UnsatisfiedLinkError: dlopen failed: cannot locate symbol "pthread_cond_clockwait"

Issue

  1. I am trying to import native libraries(.so files) into the android studio.
  2. I created a jniLibs folder and directory with ABI name and respective .so files in it.
    made changes in build.gradle and tried to load them.
  3. Then, the error occurs of java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "pthread_cond_clockwait"
    can someone give idea how to solve this issue?

Solution

That API is only available on API 30+ devices (note the __INTRODUCED_IN(30)):

int pthread_cond_clockwait(pthread_cond_t* __cond,
                           pthread_mutex_t* __mutex,
                           clockid_t __clock,
                           const struct timespec* __timeout) __INTRODUCED_IN(30);

You’re probably seeing the problem on an older device.

As per the Android documentation, it is important to realize that the NDK API level is your app’s minimum supported API level:

The API level you build against with the NDK has a very different meaning than compileSdkVersion does for Java. The NDK API level is your app’s minimum supported API level. In ndk-build, this is your APP_PLATFORM setting. With CMake, this is -DANDROID_PLATFORM.

So you need to compile the library with the correct NDK API level:

Problem: Your NDK API level is higher than the API supported by your device.

Solution: Set your NDK API level (APP_PLATFORM) to the minimum version of Android your app supports.

Answered By – Dan Albert

Answer Checked By – Marilyn (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published