3

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

Jernej Jerin
  • 3,179
  • 9
  • 37
  • 53
  • I am also facing same issue for scanLibrary if I convert it in kotlin otherwise it's working in java with static block. Let me know if you found any solution – Shweta Chauhan Jun 12 '21 at 07:29
  • are you using proguard? – rahul.taicho Jun 12 '21 at 07:51
  • No, that was actually the first thing to do after I got this issue, disabling proguard. But that didn't fix the issue. – Jernej Jerin Jun 13 '21 at 08:31
  • Could you confirm if the `jingle_peerconnection.so` packaged for all ABIs (arm, arm64, x86, x86_64) in your apk? You could drop the apk in Studio and check under `libs/` path – rahul.taicho Jun 14 '21 at 03:46

1 Answers1

0

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
Shweta Chauhan
  • 6,739
  • 6
  • 37
  • 57
  • Tried loading via `companion object` call but it did not work. Not sure though why I would need to do that, because when using `org.webrtc` version I don't have to load anything. Seems more like a library issue for Kotlin? – Jernej Jerin Jun 13 '21 at 09:09
  • possible because same thing happens to me for "scanLibrary". If I convert code in kotlin it's not working and giving java.lang.UnsatisfiedLinkError. While if I convert code in java then it's working with "static" block. – Shweta Chauhan Jun 14 '21 at 04:43
  • 1
    I've opened an issue at Github library page https://github.com/twilio/video-quickstart-android/issues/643, as I think this is something related to native build jingle_peerconnection_so.so file. – Jernej Jerin Jun 14 '21 at 19:42