无法加载(找到)j2v8_android_x86 库 [英] Couldn't load (find) j2v8_android_x86 library

查看:42
本文介绍了无法加载(找到)j2v8_android_x86 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 j2v8_android 2.2.1 的 gradle 项目 库(为 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.solibj2v8_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.2Hudl2 上执行.

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 模块可能是为旧版本打包的,因此没有在构建时将它们复制到正确的目录中 - 或者可能只是配置错误.

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屋!

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