Why can't my flutter plugin load Android NDK C++ library?

274 views
Skip to first unread message

vaton...@gmail.com

unread,
Apr 9, 2019, 3:38:20 AM4/9/19
to Flutter Dev

First,I uploaded a Android library include C++ library to the Bintray,then i built a Flutter plugin depending on this library.The program will abort when i call the jni function.And the logs showed that it failed to load native library.

I tested my Android library,it works well in the normal Android project.

//this is my plugin's dependency

dependencies {
    implementation 'tv.mudu:mrtc:1.0.1'
}

//logs

I/org.webrtc.Logging( 2442): EglBase14: SDK version: 23. isEGL14Supported: true
I/org.webrtc.Logging( 2442): NativeLibrary: Loading native library: jingle_peerconnection_so
I/org.webrtc.Logging( 2442): NativeLibrary: Loading library: jingle_peerconnection_so
E/org.webrtc.Logging( 2442): NativeLibrary: Failed to load native library: jingle_peerconnection_so
E/org.webrtc.Logging( 2442): NativeLibrary: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.mrtc_example-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.mrtc_example-2/lib/arm64, /data/app/com.example.mrtc_example-2/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libjingle_peerconnection_so.so"
E/org.webrtc.Logging( 2442): NativeLibrary: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.mrtc_example-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.mrtc_example-2/lib/arm64, /data/app/com.example.mrtc_example-2/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libjingle_peerconnection_so.so"
E/org.webrtc.Logging( 2442):    at java.lang.Runtime.loadLibrary(Runtime.java:367)
E/org.webrtc.Logging( 2442):    at java.lang.System.loadLibrary(System.java:1076)
E/org.webrtc.Logging( 2442):    at org.webrtc.NativeLibrary$DefaultLoader.load(NativeLibrary.java:21)
E/org.webrtc.Logging( 2442):    at org.webrtc.NativeLibrary.initialize(NativeLibrary.java:44)
E/org.webrtc.Logging( 2442):    at org.webrtc.PeerConnectionFactory.initialize(PeerConnectionFactory.java:238)
E/org.webrtc.Logging( 2442):    at mudu.mrtc.MRTCPuller.configuration(MRTCPuller.java:193)
E/org.webrtc.Logging( 2442):    at mudu.mrtc.MRTCPuller.<init>(MRTCPuller.java:70)
E/org.webrtc.Logging( 2442):    at com.example.mrtc.MrtcPlugin.onMethodCall(MrtcPlugin.java:95)
E/org.webrtc.Logging( 2442):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:201)
E/org.webrtc.Logging( 2442):    at io.flutter.view.FlutterNativeView$PlatformMessageHandlerImpl.handleMessageFromDart(FlutterNativeView.java:188)
E/org.webrtc.Logging( 2442):    at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:202)
E/org.webrtc.Logging( 2442):    at android.os.MessageQueue.nativePollOnce(Native Method)
E/org.webrtc.Logging( 2442):    at android.os.MessageQueue.next(MessageQueue.java:328)
E/org.webrtc.Logging( 2442):    at android.os.Looper.loop(Looper.java:164)
E/org.webrtc.Logging( 2442):    at android.app.ActivityThread.main(ActivityThread.java:5811)
E/org.webrtc.Logging( 2442):    at java.lang.reflect.Method.invoke(Native Method)
E/org.webrtc.Logging( 2442):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
E/org.webrtc.Logging( 2442):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:768)
E/art     ( 2442): No implementation found for void org.webrtc.PeerConnectionFactory.nativeInitializeAndroidGlobals() (tried Java_org_webrtc_PeerConnectionFactory_nativeInitializeAndroidGlobals and Java_org_webrtc_PeerConnectionFactory_nativeInitializeAndroidGlobals__)
E/flutter ( 2442): [ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(40)] java.lang.UnsatisfiedLinkError: No implementation found for void org.webrtc.PeerConnectionFactory.nativeInitializeAndroidGlobals() (tried Java_org_webrtc_PeerConnectionFactory_nativeInitializeAndroidGlobals and Java_org_webrtc_PeerConnectionFactory_nativeInitializeAndroidGlobals__)
E/flutter ( 2442):  at org.webrtc.PeerConnectionFactory.nativeInitializeAndroidGlobals(Native Method)
E/flutter ( 2442):  at org.webrtc.PeerConnectionFactory.initialize(PeerConnectionFactory.java:239)
E/flutter ( 2442):  at mudu.mrtc.MRTCPuller.configuration(MRTCPuller.java:193)
E/flutter ( 2442):  at mudu.mrtc.MRTCPuller.<init>(MRTCPuller.java:70)
E/flutter ( 2442):  at com.example.mrtc.MrtcPlugin.onMethodCall(MrtcPlugin.java:95)
E/flutter ( 2442):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:201)
E/flutter ( 2442):  at io.flutter.view.FlutterNativeView$PlatformMessageHandlerImpl.handleMessageFromDart(FlutterNativeView.java:188)
E/flutter ( 2442):  at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:202)
E/flutter ( 2442):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter ( 2442):  at android.os.MessageQueue.next(MessageQueue.java:328)
E/flutter ( 2442):  at android.os.Looper.loop(Looper.java:164)
E/flutter ( 2442):  at android.app.ActivityThread.main(ActivityThread.java:5811)
E/flutter ( 2442):  at java.lang.reflect.Method.invoke(Native Method)
E/flutter ( 2442):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
E/flutter ( 2442):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:768)
E/flutter ( 2442): 
F/flutter ( 2442): [FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(77)] Check failed: CheckException(env). 
F/libc    ( 2442): Fatal signal 6 (SIGABRT), code -6 in tid 2442 (le.mrtc_example)
Lost connection to device.





Reply all
Reply to author
Forward
0 new messages