命名空间“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");
}
# 1 楼答案
从《牛轧糖》开始,安卓系统就阻止了私有符号与系统库的运行时链接(见安卓开发者中的this blogpost)。 你有两个选择:
/system/lib/
中查找它们;或者/system/etc/public.libraries.txt
来实现李># 2 楼答案
我也遇到了这个错误。我的观察如下:
错误案例:
将
so
文件放入libs/yourCpuModel(armeabi-v7a)/
目录发生此错误将
so
文件放入src/jniLibs/youtCpuModel(armeabi-v7a)/
目录发生此错误但是,当我将
so
文件放入src/main/jniLibs/yourCpuModel(armeabi-v7a)/
时,没有发生错误我不知道为什么。也许对你有帮助