我有一个gradle项目,它使用
j2v8_android 2.2.1库(为V8 JS引擎提供Java绑定 – android端口).不幸的是,在执行项目后(构建成功没有问题),我得到一个与缺少j2v8_android_x86库文件相关的异常.尝试创建V8运行时会出现问题:
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).如果我理解正确,那些文件的名称和位置是正确的,应该解决它们.
该应用程序由Gradle 2.2.1(在Oracle JVM 1.8.0_45上)编译和打包,兼容Android SDK 19(支持语言级别1.7),并在运行Android 4.4.2的Hudl2上执行.