UnsatisfiedLinkError when using Twilio JavaI420Buffer (Kotlin)

Viewed 323

Description

When trying to allocate JavaI420Buffer via the following call:

tvi.webrtc.JavaI420Buffer.allocate(width, height)

I get the following error:

java.lang.UnsatisfiedLinkError: No implementation found for java.nio.ByteBuffer tvi.webrtc.JniCommon.nativeAllocateByteBuffer(int) (tried Java_tvi_webrtc_JniCommon_nativeAllocateByteBuffer and Java_tvi_webrtc_JniCommon_nativeAllocateByteBuffer__I)
        at tvi.webrtc.JniCommon.nativeAllocateByteBuffer(Native Method)
        at tvi.webrtc.JavaI420Buffer.allocate(JavaI420Buffer.java:87)
        at dji.ux.beta.core.widget.fpv.FPVWidget$onSurfaceTextureAvailable$yuvDataListener$1.onYuvDataReceived(FPVWidget.kt:417)

Before this error I also get:

2021-05-28 08:31:27.367 15131-15131/? I/tvi.webrtc.Logging: NativeLibrary: Loading native library: jingle_peerconnection_so
2021-05-28 08:31:27.367 15131-15131/? I/tvi.webrtc.Logging: NativeLibrary: Loading library: jingle_peerconnection_so
2021-05-28 08:31:27.369 15131-15131/? E/tvi.webrtc.Logging: NativeLibrary: Failed to load native library: jingle_peerconnection_so
2021-05-28 08:31:27.369 15131-15131/? E/tvi.webrtc.Logging: NativeLibrary: java.lang.UnsatisfiedLinkError: dlopen failed: library "libjingle_peerconnection_so.so" not found
2021-05-28 08:31:27.370 15131-15131/? E/tvi.webrtc.Logging: NativeLibrary: java.lang.UnsatisfiedLinkError: dlopen failed: library "libjingle_peerconnection_so.so" not found

Strangely if I declare to use official org.webrtc library (implementation 'org.webrtc:google-webrtc:1.0.32006') then native call to allocate byte buffer succeeds.

Video Android SDK Version

com.twilio:video-android-ktx:6.3.0

1 Answers

First of all when you load native code in kotlin it should be like this:

companion object {
    init {
        System.loadLibrary("jingle_peerconnection")
    }
}

In Java

static {
    System.loadLibrary("jingle_peerconnection")
}

Second as per your error, "library "libjingle_peerconnection_so.so" not found => you have to add related Android architectures folder in "main -> java -> libs" folder

Example : main -> java -> libs -> x86 -> .so file
Related