gpt4 book ai didi

Android NDK & FFMPEG : findLibrary returned null

转载 作者:太空狗 更新时间:2023-10-29 14:10:50 29 4
gpt4 key购买 nike

我正在使用它在 ndk 上构建 ffmpeg: roman10's android ndk r9d - ffmpeg tutorial

链接显示了如何编译,但不清楚如何使用它。有人可以指导我吗?谢谢。

在从我的项目根目录构建 ndk 之后,我能够在 libs/armeabiobj/local/armeabi 中生成 .so 文件。现在我得到了 < strong>findLibrary 返回 null??现在要做什么?

java.lang.UnsatisfiedLinkError: Couldn't load libavutil from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.palak.androidffmpegroman-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.palak.androidffmpegroman-2, /vendor/lib, /system/lib]]]: findLibrary returned null

at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at com.palak.androidffmpegroman.MainActivity.<clinit>(MainActivity.java:175)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2101)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)

我的项目结构:

enter image description here

我的build_android.sh

  #!/bin/bash
NDK=$HOME/NDK/android-ndk-r10d
SYSROOT=$NDK/platforms/android-19/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86
function build_one
{
sudo ./configure \
--prefix=$PREFIX \
--enable-shared \
--disable-static \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-doc \
--disable-symver \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--target-os=linux \
--arch=arm \
--enable-cross-compile \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}
CPU=arm
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS="-marm"
build_one

我正在使用 Ndk r10、ffmpeg 2.5.4、ubuntu x86。

编辑:Android.mk

LOCAL_PATH:= /home/palak/NDK/ffmpeg-2.5.4/android/arm

include $(CLEAR_VARS)
LOCAL_MODULE:= libavcodec
LOCAL_SRC_FILES:= lib/libavcodec-56.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE:= libavformat
LOCAL_SRC_FILES:= lib/libavformat-56.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE:= libswscale
LOCAL_SRC_FILES:= lib/libswscale-3.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE:= libavutil
LOCAL_SRC_FILES:= lib/libavutil-54.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE:= libavfilter
LOCAL_SRC_FILES:= lib/libavfilter-5.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE:= libswresample
LOCAL_SRC_FILES:= lib/libswresample-1.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

jni文件夹下的Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := tutorial01
LOCAL_SRC_FILES := tutorial01.c
LOCAL_LDLIBS := -llog -ljnigraphics -lz
LOCAL_SHARED_LIBRARIES := avformat avcodec swscale avutil

include $(BUILD_SHARED_LIBRARY)
$(call import-module,ffmpeg-2.5.4/android/arm)

最佳答案

LOCAL_MODULE:= libavutil

-->

LOCAL_MODULE:= avutil # libavutil.so

示例(曾经有效): https://github.com/18446744073709551615/reDroid/blob/master/jni/Android.mk

更新:
再次重申:您不需要在库名称中使用 lib 前缀;
LOCAL_MODULE:= avutil 将为您提供 libavutil.so

其次,您将什么参数传递给 loadLibrary()?同样,对于 libavutil.so,它应该是 "avutil"

如果遇到问题,最好的方法是从 NDK 中的 hello-jni 示例开始(your-ndk-dir/samples/hello-jni/ )

/* this is used to load the 'hello-jni' library on application
* startup. The library has already been unpacked into
* /data/data/com.example.hellojni/lib/libhello-jni.so <== !!!!!!!!!!!!!
* at installation time by the package manager.
*/
static {
System.loadLibrary("hello-jni");
}

示例编译并运行后,您可以将您的库添加到其中并让您的东西工作。

关于Android NDK & FFMPEG : findLibrary returned null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28625627/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com