AndroidRuntime引起的:java.lang.unsatisfiedLinkError:无法加载tfp_jni:findLibrary返回null [英] AndroidRuntime Caused by: java.lang.unsatisfiedLinkError: Couldn't load tfp_jni: findLibrary returned null

查看:168
本文介绍了AndroidRuntime引起的:java.lang.unsatisfiedLinkError:无法加载tfp_jni:findLibrary返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,看起来像我的那样有很多问题,但是不能肯定这些问题与我的问题有关。好。我有一个使用SDK作为引用库的Android项目。 SDK包含C ++,所以我使用的是android-ndk-r9库。我在Android项目中引用的SDK是一个JNI库(Oooooo - 可怕的东西)。哦,不要让我忘记提到armeabi-v7a(这似乎是另一个可怕的主题)。执行此行时,我的错误发生:

So, it looks like there are a lot of issues like mine out there but not sure any of them are related to my issue. OK. I have an Android project that uses an SDK as a referenced library. The SDK contains C++, so I am using the android-ndk-r9 library. The SDK that I reference in my Android project is a JNI library (Oooooo - scary stuff). Oh yeah, don't let me forget to mention armeabi-v7a (which appears to be another scary subject). My error occurs when this line is executed:

 System.loadLibrary("tfp_jni");

tfp_jni在我的SDK库的libs文件夹中的armeabi-v7a文件夹下是一个libtfp_jni.so文件项目。该SDK库项目包含一个Android.mk文件。我不认为代码在那里。但是这里是.mk文件的内容:

tfp_jni is really a libtfp_jni.so file under the armeabi-v7a folder in libs folder of my SDK library project. That SDK library project contains an Android.mk file. I do not think the code is getting in there. But here is the contents of that .mk file:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := tfp-prebuilt
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/libtfp_jni.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

然后在我的Android项目中,我有一个jni文件夹,其中包含一个Android.mk和Application.mk。以下是内容:

Then in my Android project, I have a jni folder containing an Android.mk and an Application.mk. Here are the contents:

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

OPENCV_INSTALL_MODULES:=on
OPENCV_INSTALL_CAMERA:=off

include $(INNERID_ANDROID_ROOT)/Android.mk
include $(OPENCV_ANDROID_ROOT)/sdk/native/jni/OpenCV.mk

Application.mk

APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-14

环境变量

路径和符号 - 包括

除了显示源位置和输出位置之外,所有其他选项卡都为空项目文件夹。

All other tabs are empty except for the Source Location and Output Location, which displays the project folder.

Android项目&偏好设置

我从Stackoverflow中的类似问题中尝试过其他各种各样的答案,没有成功。请让我知道,如果还有其他任何你需要看到的,我会尽快提供其他信息。

I have tried various other answers from the similar questions on Stackoverflow with no success. Please let me know if there is anything else you need to see and I'll provide the additional information as soon as possible.

谢谢。

----------------------------------------- ---------------- 新图片 ------------------------- ------------------------

--------------------------------------------------------- New Image -------------------------------------------------

更正! apk是在verify-demo-nolic项目/ bin文件夹中。参考库tfp_java.jar是SDK库项目。您可以从Finder看到.so文件在libs中。这是否有帮助?

Correction! The apk is in the verify-demo-nolic project /bin folder. The Referenced Library tfp_java.jar is the SDK library project. You can see from Finder that the .so file is in libs. Does this help?

推荐答案

必须出现一些事情才能使链接工作

A number of things must occur for the linkage to work


  1. 本地库必须编译为.so文件以获取适当的ABI - 这通常通过 ndk-build 脚本/批处理文件,尽管也可以使用生成的独立工具链来完成。 IDE项目可能希望将其配置为自定义构建步骤。

  1. The native library must be compiled to an .so file for the appropriate ABI(s) - this is typically accomplished via the ndk-build script/batch file, though it can also be done using a generated stand alone toolchain. IDE projects may want to configure running this as a custom build step.

本机库必须打包在应用程序.apk中。如果它是从应用程序项目目录下的jni /文件夹构建的,那么 ndk-build 可能将其复制到项目的libs /文件夹的ABI适当的子目录中。但是,如果本机库属于不同的Android库,则可能需要额外的步骤。特别是,.so 不能通过构建系统从库.jar 获得,因此与库代码相关联的代码必须通过在客户端项目的libs /文件夹下显式复制,否则发现通过引用包含它的库项目目录树(不是孤独的.jar )。

The native library must get packaged in the application .apk. If it was built from a jni/ folder under an application project directory, then ndk-build probably copied it into an ABI-appropriate subdirectory of the libs/ folder of the project. However, if the native library belongs to a distinct Android library, extra steps may be required. In particular, a .so cannot be obtained by the build system from a library .jar and so one associated with library code must either by explicitly copied under the libs/ folder of the client project, or else found by referencing a library project directory tree (not a lonely .jar) which includes it.

设备上的安装程序必须确定.apk中包含的.so文件之一适用于设备的ABI(架构),并将其复制出来的.apk进入安装目录以供使用。

The installer on the device must decide that one of the .so files contained in the .apk is appropriate for the device's ABI (architecture) and copy it out of the .apk into the install directory for use.

jni函数的运行时连接名称(任何编译器名称的下游)都必须匹配那些虚拟机正在寻找。通常,这里的问题来自于在本机函数名称中不正确编码java完全限定类名。

The runtime linkage names of the jni functions (downstream of any compiler name-mangling) must match those which the VM is looking for. Typically, problems here come up from not correctly encoding the java fully qualified class name in the native function name. The javah tool is intended to help avoid such mistakes, though with care it can be done manually.

$ javah 工具旨在帮助避免这种错误,尽管可以手动完成。 b
$ b

这些步骤中的每一个都显示出潜在的细目,因此可以尝试找到.so文件丢失的第一个阶段来调试不满意的链接。

Each of these steps presents a potential breakdown, so debugging an unsatisfied link can be approached by trying to find the first stage at which the .so file goes missing.

这篇关于AndroidRuntime引起的:java.lang.unsatisfiedLinkError:无法加载tfp_jni:findLibrary返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆