简体   繁体   English

带有.So库的Android NDK / JNI UnsatisfiedLinkError

[英]Android NDK/JNI UnsatisfiedLinkError With .So library

I'm new to Android NDK, and I'm currently trying to build a RTMP C client for Android (and later iOS). 我是Android NDK的新手,目前正在尝试为Android(及更高版本的iOS)构建RTMP C客户端。 Currently, I'm running into an issue where the application crashes as soon as I try to load my library: 当前,我遇到一个问题,即当我尝试加载我的库时,应用程序崩溃:

static {
    System.loadLibrary("test");
}

The exception I get is 我得到的例外是

java.lang.UnsatisfiedLinkError: dlopen failed: could not load library "librtmp.so.1" needed by "libtest.so"; caused by library "librtmp.so.1" not found

I'm honestly completely lost. 老实说,我完全迷路了。 ndk-build doesn't return any errors: ndk-build不返回任何错误:

[armeabi] Prebuilt       : rtmp.so <= jni/rtmp/
[armeabi] Install        : rtmp.so => libs/armeabi/rtmp.so
[armeabi] Compile thumb  : test <= RTMPClient.c
[armeabi] SharedLibrary  : libtest.so
[armeabi] Install        : libtest.so => libs/armeabi/libtest.so

I've tried loading in the rtmp librarary via System.loadLibrary("rtmp") , but no dice. 我尝试通过System.loadLibrary("rtmp")加载rtmp库,但没有骰子。

Android.mk Android.mk

LOCAL_PATH:= $(call my-dir)
LIBS_PATH := libs/$(TARGET_ARCH_ABI)

include $(CLEAR_VARS)
LOCAL_MODULE := rtmp
LOCAL_SRC_FILES := rtmp/rtmp.so
LOCAL_C_INCLUDES := rtmp/
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := test
LOCAL_SRC_FILES := RTMPClient.c
LOCAL_LDLIBS    := -llog
LOCAL_SHARED_LIBRARIES += rtmp

include $(BUILD_SHARED_LIBRARY)

Application.mk Application.mk

APP_PLATFORM:=android-19

My RTMPClient.c uses some structs and functions from rtmp like so: 我的RTMPClient.c使用rtmp一些结构和功能,如下所示:

#include <rtmp/rtmp.h>

I'm not sure where librtmp.so.1 is coming from, but I also found it in my libtest.so with arm-linux-andrioideabi-readelf: 我不确定librtmp.so.1的来源,但是我也可以在libtest.so中使用arm-linux-andrioideabi-readelf找到它:

0x00000001 (NEEDED)                     Shared library: [librtmp.so.1]

Any ideas on how I can fix this? 关于如何解决此问题的任何想法?

EDIT: I got the rtmp.so file from here . 编辑:我从这里得到rtmp.so文件。 I was sent there from the KODI librtmp update page 我是从KODI librtmp更新页面发送到那里

I ended up throwing out my rtmp.so file, and instead grabbed the jni files from rtmpdump-android . 我最终丢掉了rtmp.so文件,而是从rtmpdump-android中获取了jni文件。 After putting those file in, changing my android.mk file to: 将这些文件放入后,将我的android.mk文件更改为:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_SRC_FILES += \
    librtmp/amf.c \
    librtmp/hashswf.c \
    librtmp/log.c \
    librtmp/parseurl.c \
    librtmp/rtmp.c

LOCAL_CFLAGS := -D__STDC_CONSTANT_MACROS -DNO_CRYPTO
LOCAL_LDLIBS := -llog
LOCAL_MODULE := librtmp

include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := dump
LOCAL_CFLAGS := -DRTMPDUMP_VERSION=\"v2.4\"
LOCAL_LDLIBS := -llog
LOCAL_SRC_FILES := dump/rtmpdump.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../librtmp
LOCAL_C_INCLUDES += dump/rtmpdump.h

LOCAL_STATIC_LIBRARIES := librtmp

include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := test
LOCAL_SRC_FILES := nelly.c nelly_tables.c RTMPClient.c
LOCAL_LDLIBS    := -llog
LOCAL_SHARED_LIBRARIES += dump

include $(BUILD_SHARED_LIBRARY)

And changing my RTMPClient.c file to include #include "librtmp/rtmp.h" instead of #include <rtmp/rtmp.h> , the file compiled and ran on my device without any issues. 并将我的RTMPClient.c文件更改为包括#include "librtmp/rtmp.h"而不是#include <rtmp/rtmp.h> ,该文件已编译并在我的设备上运行,没有任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 android NDK加载库-UnsatisfiedLinkError - android NDK loading a library - UnsatisfiedLinkError Android NDK使用JNI中C代码的.so库 - Android NDK use .so library from c code inside JNI Unsatisfiedlinkerror:无法在Nfc系统应用程序中加载自定义NDK JNI库 - Unsatisfiedlinkerror: Unable to load custom NDK JNI library in Nfc system app Android NDK共享库UnsatisfiedLinkError OpenGLESv2 - Android NDK Shared Library UnsatisfiedLinkError OpenGLESv2 在Android NDK中重命名依赖库会导致UnsatisfiedLinkError - Renaming dependent library in Android NDK causes UnsatisfiedLinkError 尝试加载预编译的 .so Android NDK(异常 java.lang.UnsatisfiedLinkError: dlopen failed: library) - Try to load precompiled .so Android NDK (Exception java.lang.UnsatisfiedLinkError: dlopen failed: library) Android Jni .so文件ExceptionInInitializerError和UnsatisfiedLinkError:未找到库jniopencv_core - Android Jni .so files ExceptionInInitializerError and UnsatisfiedLinkError: Library jniopencv_core not found hello-jni示例上的Android NDK java.lang.UnsatisfiedLinkError - Android NDK java.lang.UnsatisfiedLinkError on sample hello-jni Android Studio调试NDK / JNI Mapbox库 - Android Studio Debug NDK/JNI Mapbox Library Android NDK cmake JNI 静态库 - Android NDK cmake JNI static library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM