简体   繁体   中英

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). 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:

[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.

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

APP_PLATFORM:=android-19

My RTMPClient.c uses some structs and functions from rtmp like so:

#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:

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

Any ideas on how I can fix this?

EDIT: I got the rtmp.so file from here . I was sent there from the KODI librtmp update page

I ended up throwing out my rtmp.so file, and instead grabbed the jni files from rtmpdump-android . After putting those file in, changing my android.mk file to:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM