有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

命名空间“classloadernamespace”无法访问java库

我想在我的Android Studio项目中导入以下库,这些库位于/system/lib64/文件夹中。 我的错误率低于

2020-01-06 13:23:31.358 5171-5171/org.strongswan.安卓 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: org.strongswan.安卓, PID: 5171
    java.lang.UnsatisfiedLinkError: dlopen failed: library "/system/lib64/libstrongswan.so" needed or dlopened by "/system/lib64/libnativeloader.so" is not accessible for the namespace "classloader-namespace"
        at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
        at java.lang.System.loadLibrary(System.java:1669)
        at org.strongswan.安卓.logic.CharonVpnService.<init>(CharonVpnService.java:730)
        at java.lang.Class.newInstance(Native Method)
        at 安卓.app.AppComponentFactory.instantiateService(AppComponentFactory.java:103)
        at 安卓.app.ActivityThread.handleCreateService(ActivityThread.java:3740)
        at 安卓.app.ActivityThread.access$1400(ActivityThread.java:238)
        at 安卓.app.ActivityThread$H.handleMessage(ActivityThread.java:1803)
        at 安卓.os.Handler.dispatchMessage(Handler.java:106)
        at 安卓.os.Looper.loop(Looper.java:214)
        at 安卓.app.ActivityThread.main(ActivityThread.java:7073)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.安卓.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.安卓.internal.os.ZygoteInit.main(ZygoteInit.java:964)

在线系统上。loadLibrary(“strongswan”)

        System.loadLibrary("strongswan");

        if (MainActivity.USE_BYOD)
        {
            System.loadLibrary("tncif");
            System.loadLibrary("tnccs");
            System.loadLibrary("imcv");
        }

        System.loadLibrary("hydra");
        System.loadLibrary("charon");
        System.loadLibrary("ipsec");
        System.loadLibrary("安卓bridge");
    }


共 (2) 个答案

  1. # 1 楼答案

    从《牛轧糖》开始,安卓系统就阻止了私有符号与系统库的运行时链接(见安卓开发者中的this blogpost)。 你有两个选择:

    1. 在APK中包含这些库,这样就不需要在/system/lib/中查找它们;或者
    2. 修改你的Android ROM,使这些库被认为是公共的。这可以通过将这些库添加到/system/etc/public.libraries.txt来实现
  2. # 2 楼答案

    我也遇到了这个错误。我的观察如下:

    错误案例:

    1. so文件放入libs/yourCpuModel(armeabi-v7a)/ 目录发生此错误

    2. so文件放入src/jniLibs/youtCpuModel(armeabi-v7a)/ 目录发生此错误

    但是,当我将so文件放入src/main/jniLibs/yourCpuModel(armeabi-v7a)/时,没有发生错误

    我不知道为什么。也许对你有帮助