rongcloud / rongcloud-im-flutter-sdk

IM Flutter SDK of RongCloud
MIT License
199 stars 56 forks source link

Release 版 APK,实机运行出错。java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad ... #68

Closed wantg closed 4 years ago

wantg commented 4 years ago
$ flutter doctor -v
[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.17763.914], locale zh-CN)
    • Flutter version 1.12.13+hotfix.5 at D:\Applications\flutter
    • Framework revision 27321ebbad (4 weeks ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\hrbc\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = C:\Users\hrbc\AppData\Local\Android\sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[√] Android Studio (version 3.5)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 42.0.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[√] VS Code, 64-bit edition (version 1.41.1)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.7.1

[√] Connected device (1 available)
    • KNT AL20 • TWGDU16A29009520 • android-arm64 • Android 7.0 (API 24)

日志

java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/user/0/com.example.myapp/app_lib/libRongIMLib.so"
        at java.lang.Runtime.load0(Runtime.java:914)
        at java.lang.System.load(System.java:1508)
        at io.rong.imlib.y0.e.d()
        at io.rong.imlib.y0.d.c()
        at io.rong.imlib.y0.d.a()
        at io.rong.imlib.y0.c.a()
        at io.rong.imlib.y0.c.a()
        at io.rong.imlib.NativeObject.<init>()
        at io.rong.imlib.k0.a()
        at io.rong.imlib.g0.<init>()
        at io.rong.imlib.ipc.RongService.onBind()
        at android.app.ActivityThread.handleBindService(ActivityThread.java:3362)
        at android.app.ActivityThread.-wrap3(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1664)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:156)
        at android.app.ActivityThread.main(ActivityThread.java:6523)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
loginSin commented 4 years ago

找不到对应的 libRongIMLib.so 一般都是 build.gradle 中没有指明 ndk 导致的,可以试着将 ndk 指定为 armeabi-v7a 详细可以参见 demo 中的配置 https://github.com/rongcloud/rongcloud-im-flutter-sdk/blob/master/example/android/app/build.gradle

wantg commented 4 years ago

@loginSin 谢谢回复,但似乎问题不是这个。 我编译官方example也一样,执行过程如下:

1.克隆代码 git clone https://github.com/rongcloud/rongcloud-im-flutter-sdk

2.进入 example 目录 cd example

3.修改 minSdkVersion 为 22(flutter_sound 1.8 需要)

4.安装依赖 flutter pub get

5.打包 flutter build apk

6.安装到手机 build\app\outputs\apk\release\app-release.apk (7.9MB)

7.用 Android Studio 看 logcat

结果仍然是

2020-01-07 16:17:05.059 18246-18246/? E/RongLog-Push[c]: appid or appkey can't be empty when enable MI push !
2020-01-07 16:17:05.059 18246-18246/? E/RongLog-Push[c]: appid or appkey can't be empty when enable MEIZU push !
2020-01-07 16:17:05.120 18298-18298/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.rongcloud_im_plugin_example:ipc, PID: 18298
    java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/user/0/com.example.rongcloud_im_plugin_example/app_lib/libRongIMLib.so"
        at java.lang.Runtime.load0(Runtime.java:914)
        at java.lang.System.load(System.java:1508)
        at io.rong.imlib.h.g.d()
        at io.rong.imlib.h.f.c()
        at io.rong.imlib.h.f.a()
        at io.rong.imlib.h.c.a()
        at io.rong.imlib.h.c.a()
        at io.rong.imlib.NativeObject.<init>()
        at io.rong.imlib.rc.a()
        at io.rong.imlib.Ra.<init>()
        at io.rong.imlib.ipc.RongService.onBind()
        at android.app.ActivityThread.handleBindService(ActivityThread.java:3362)
        at android.app.ActivityThread.-wrap3(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1664)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:156)
        at android.app.ActivityThread.main(ActivityThread.java:6523)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
pubspec.lock ``` # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: archive: dependency: transitive description: name: archive url: "https://pub.dartlang.org" source: hosted version: "2.0.11" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted version: "1.5.2" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted version: "2.4.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted version: "1.0.5" cached_network_image: dependency: "direct main" description: name: cached_network_image url: "https://pub.dartlang.org" source: hosted version: "2.0.0" camera: dependency: "direct main" description: name: camera url: "https://pub.dartlang.org" source: hosted version: "0.5.7+2" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted version: "1.1.2" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted version: "1.14.11" convert: dependency: transitive description: name: convert url: "https://pub.dartlang.org" source: hosted version: "2.1.1" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted version: "2.1.3" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted version: "0.1.3" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted version: "5.1.0" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" flutter_audio_recorder: dependency: "direct main" description: name: flutter_audio_recorder url: "https://pub.dartlang.org" source: hosted version: "0.5.5" flutter_cache_manager: dependency: transitive description: name: flutter_cache_manager url: "https://pub.dartlang.org" source: hosted version: "1.1.3" flutter_local_notifications: dependency: "direct main" description: name: flutter_local_notifications url: "https://pub.dartlang.org" source: hosted version: "0.8.4+3" flutter_sound: dependency: "direct main" description: name: flutter_sound url: "https://pub.dartlang.org" source: hosted version: "1.8.0" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" flutter_web_plugins: dependency: transitive description: flutter source: sdk version: "0.0.0" fluttertoast: dependency: "direct main" description: name: fluttertoast url: "https://pub.dartlang.org" source: hosted version: "3.1.3" http: dependency: transitive description: name: http url: "https://pub.dartlang.org" source: hosted version: "0.12.0+4" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted version: "3.1.3" image: dependency: transitive description: name: image url: "https://pub.dartlang.org" source: hosted version: "2.1.4" image_picker: dependency: "direct main" description: name: image_picker url: "https://pub.dartlang.org" source: hosted version: "0.6.2+3" intl: dependency: transitive description: name: intl url: "https://pub.dartlang.org" source: hosted version: "0.16.1" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted version: "0.12.6" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted version: "1.1.8" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted version: "1.6.4" path_provider: dependency: "direct main" description: name: path_provider url: "https://pub.dartlang.org" source: hosted version: "1.5.1" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted version: "1.8.0+1" percent_indicator: dependency: "direct main" description: name: percent_indicator url: "https://pub.dartlang.org" source: hosted version: "2.1.1+1" permission_handler: dependency: "direct main" description: name: permission_handler url: "https://pub.dartlang.org" source: hosted version: "3.3.0" petitparser: dependency: transitive description: name: petitparser url: "https://pub.dartlang.org" source: hosted version: "2.4.0" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted version: "2.2.1" quiver: dependency: transitive description: name: quiver url: "https://pub.dartlang.org" source: hosted version: "2.0.5" rongcloud_im_plugin: dependency: "direct dev" description: path: ".." relative: true source: path version: "1.0.5" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" source_span: dependency: transitive description: name: source_span url: "https://pub.dartlang.org" source: hosted version: "1.5.5" sqflite: dependency: transitive description: name: sqflite url: "https://pub.dartlang.org" source: hosted version: "1.2.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted version: "1.9.3" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted version: "2.0.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted version: "1.0.5" synchronized: dependency: transitive description: name: synchronized url: "https://pub.dartlang.org" source: hosted version: "2.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted version: "1.1.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted version: "0.2.11" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted version: "1.1.6" uuid: dependency: transitive description: name: uuid url: "https://pub.dartlang.org" source: hosted version: "2.0.4" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted version: "2.0.8" video_player: dependency: "direct main" description: name: video_player url: "https://pub.dartlang.org" source: hosted version: "0.10.5+1" video_player_platform_interface: dependency: transitive description: name: video_player_platform_interface url: "https://pub.dartlang.org" source: hosted version: "1.0.4" video_player_web: dependency: transitive description: name: video_player_web url: "https://pub.dartlang.org" source: hosted version: "0.1.1+1" xml: dependency: transitive description: name: xml url: "https://pub.dartlang.org" source: hosted version: "3.5.0" sdks: dart: ">=2.6.0 <3.0.0" flutter: ">=1.12.13+hotfix.4 <2.0.0" ```
wantg commented 4 years ago

将 android/app/build.gradle 修改为如下配置可解决

android {
    ...
    buildTypes {
        release {
            ...
            shrinkResources false
            minifyEnabled false
        }
    }
    ...
}

详见:https://github.com/flutter/flutter/issues/47527