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

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

问题描述

所以,它看起来像有很多像我这样的问题在那里,但不知道其中任何一个都与我的问题。好。我有一个使用SDK作为一个引用的库的Andr​​oid项目。该SDK包含了C ++,所以我使用了android-NDK-R9库。我在我的Andr​​oid项目的参考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库项目的库文件夹中的armeabi-V7A文件夹中的libtfp_jni.so文件。该SDK库项目包含一个Android.mk文件。我不认为code越来越在那里。但这里要说的是的.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)

然后在我的Andr​​oid项目,我有包含Android.mk和Application.mk JNI的文件夹。以下是内容:

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项目及放大器; preferences

我试图从类似的问题对#1,但没有成功各种各样的答案。请让我知道是否有你需要看别的,我会尽快提供更多的信息成为可能。

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是在验证,演示nolic项目/ bin文件夹。引用的库tfp_java.jar是SDK库项目。您可以从Finder中看到,.so文件是库。这是否帮助?

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(S) - 这是通过 NDK建造脚本/批典型地文件,尽管它也可以用一个产生独立的工具链完成。 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建造可能把它复制到库的ABI相适应的子目录中的项目/文件夹中。的然而,如果本地库属于一个不同的机器人的库,则可能需要额外的步骤的。特别是,一个.so 不能被构建系统从图书馆获得的.jar 并因此一个带库code关联必须通过在客户端项目的库/文件夹中明确复制,或者通过引用库项目目录树中(不是一个孤独的.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全限定类名。该 javah的工具旨在帮助避免这样的错误,虽然小心就可以手动完成。

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.

每个步骤$ P $的psents一个潜在的故障,所以调试一个不合适的链接可以试图寻找其中的.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天全站免登陆