无法加载(查找)j2v8_android_x86库 [英] Couldn't load (find) j2v8_android_x86 library
问题描述
我有一个gradle项目,该项目使用 j2v8_android 2.2.1
库(为V8 JS引擎提供Java绑定-android端口).不幸的是,在执行项目后(构建成功,没有问题),我得到了与缺少j2v8_android_x86
库文件有关的异常.尝试创建V8
运行时时会出现问题:
I have a gradle project that uses j2v8_android 2.2.1
library (which provides Java bindings for V8 JS engine - android port). Unfortunately, after executing the project (build succeeds without issues), I get an exception related to missing j2v8_android_x86
library file. The issues occurs when trying to create V8
runtime:
V8 runtime = V8.createV8Runtime();
异常本身是:
Caused by: java.lang.IllegalStateException: J2V8 native library not loaded.
at com.eclipsesource.v8.V8.checkNativeLibraryLoaded(V8.java:86)
at com.eclipsesource.v8.V8.createV8Runtime(V8.java:74)
at com.eclipsesource.v8.V8.createV8Runtime(V8.java:63)
(...)
Caused by: java.lang.UnsatisfiedLinkError: Could not load J2V8 library. Reasons:
Couldn't load j2v8_android_x86 from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.androidscripting.app-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.androidscripting.app-1, /vendor/lib, /system/lib, /system/lib/arm]]]: findLibrary returned null
at com.eclipsesource.v8.LibraryLoader.loadLibrary(LibraryLoader.java:71)
at com.eclipsesource.v8.V8.load(V8.java:49)
at com.eclipsesource.v8.V8.createV8Runtime(V8.java:72)
... 17 more
当我调查apk
时,在apk
的根目录中看到两个库文件(libj2v8_android_armv7l.so
和 libj2v8_android_x86.so
).如果我正确理解,则这些文件的名称和位置是正确的,应该将其解析.
When I investigate the apk
I see two library files at the root of the apk
(libj2v8_android_armv7l.so
and libj2v8_android_x86.so
). If I understand it correctly, the names and location of those files is correct and they should be resolved.
应用程序由Gradle 2.2.1
(在Oracle JVM 1.8.0_45
上)具有Android SDK 19
兼容性(具有语言级别支持1.7
)进行编译和打包,并在运行Android 4.4.2
的Hudl2
上执行.
The application is compiled and packaged by Gradle 2.2.1
(on Oracle JVM 1.8.0_45
) with Android SDK 19
compatibility (with language level support 1.7
) and executed on Hudl2
running Android 4.4.2
.
推荐答案
与我的大学交流后,我们找到了解决方案.路径类加载器实际上并不位于apk
的根目录下-而是位于libs/[ARCHITECTURE]
中.将libj2v8_android_x86.so
文件移动到libs/x86
并重新打包确实解决了该问题.
After speaking to my colleges we found a solution. The path class loader does not actually look under the root of the apk
- instead it looks in libs/[ARCHITECTURE]
. Moving the libj2v8_android_x86.so
file to libs/x86
and repackaging did solve the problem.
我想maven模块可能已经被打包为较旧的版本,因此没有将它们复制到build的正确目录中-或可能只是配置错误.
I suppose the maven module may have been packaged for an older version and thus did not copy them into the correct directory on build - or may simply be misconfigured.
这篇关于无法加载(查找)j2v8_android_x86库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!