我有一个带有原生.so库的apk,为所有架构编译:armabi,mips,x86和x86_64。我想在我的java应用程序中使用这些库。
正如我想的那样,为了在桌面上构建应用程序,我需要在我的PC上的任何地方从x86_64文件夹中复制.so文件,我已将其复制到〜/ IdeaProjects / ecg / lib / x86_64。之后,我按如下方式提供到此文件的VM路径:-Djava.library.path=/home/user/IdeaProjects/ecg/lib/x86_64
然后我编写了在我的项目中使用这个库的包装器。在包装器的静态初始化程序中,我试图像这样加载库(我的库文件名为libnative-lib.so):
static
{
System.loadLibrary("native-lib");
}
在加载库期间,我收到此异常:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/user/IdeaProjects/ecg/lib/x86_64/libnative-lib.so: liblog.so: cannot open shared object file: no such file or directory
那么liblog.so是什么?我在哪里可以得到它?我试图挖掘所有我发现的是为github上的不同拱门编译liblog.so。我找到了x86_64 there的一个,把它放在我原生的lib文件附近,但异常并没有消失。
我能为实现目标做些什么?
UPD
sudo apt install android-liblog && android-liblog-dev
并提供LD_LIBRARY_PATH = / usr / lib / android解决此问题。但现在我收到了下一个错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/user/IdeaProjects/ecg/lib/x86_64/libnative-lib.so: /usr/lib/x86_64-linux-gnu/libm.so: invalid ELF header
UPDUPD 最后我已经从android sdk文件夹(Sdk / ndk-bundle / platforms / android -24 / arch-x86_64 / usr / lib64)复制了所有依赖库,并且异常已经消失。现在应用程序完全符合此报告:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x0000000000000000, pid=11338, tid=0x00007ffaccb05700
#
# JRE version: OpenJDK Runtime Environment (8.0_131-b11) (build 1.8.0_131-8u131-b11-2ubuntu1.16.04.3-b11)
# Java VM: OpenJDK 64-Bit Server VM (25.131-b11 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C 0x0000000000000000
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/user/IdeaProjects/ecg/hs_err_pid11338.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.