library is not accessible for the namespace "classloader-namespace"
Asked Answered
B

2

9

I want to import below libraries in my Android Studio Project these are placed in /system/lib64/ folder. I am getting below error

2020-01-06 13:23:31.358 5171-5171/org.strongswan.android E/AndroidRuntime: FATAL EXCEPTION: main
    Process: org.strongswan.android, 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.android.logic.CharonVpnService.<init>(CharonVpnService.java:730)
        at java.lang.Class.newInstance(Native Method)
        at android.app.AppComponentFactory.instantiateService(AppComponentFactory.java:103)
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3740)
        at android.app.ActivityThread.access$1400(ActivityThread.java:238)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1803)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7073)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)

on the line System.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("androidbridge");
    }

Brinkmanship answered 6/1, 2020 at 8:30 Comment(3)
can some one help me on it..??Brinkmanship
#52515809 did you check this threadYockey
@sashabeliy yes I have already checked these threads but unable to handle this error till now. I have also read docs of android developer from where i get that if targetVersionSDK is greater then or equal 24 then it will generate RunTimeError while for below then 24 this is working perfectly. developer.android.com/about/versions/nougat/…Brinkmanship
R
18

From Nougat onwards, Android prevents the runtime linkage of private symbols from system libraries (see this blogpost in Android Developers). You have two options:

  1. Include those libraries in your APK so that you don't need to look for them in /system/lib/; or
  2. Modify your Android ROM so that those libraries are considered public. This can be done by adding those libraries to /system/etc/public.libraries.txt.
Rampant answered 31/3, 2020 at 11:45 Comment(1)
If you are super brave, you can read libart.so address out of /proc/self/maps and then look in Ghidra for where symbols would be relative to the address loaded in memory.Greaser
C
2

I also meet this error.The situation I tested is like this.

I put the so file in the [libs/yourCpuModel(armeabi-v7a)/] directory will be this error.

I put the so file in the [src/jniLibs/youtCpuModel(armeabi-v7a)/] directory will be this error.

But I put the so file in the [src/main/jniLibs/yourCpuModel(armeabi-v7a)/] directory will not.

I don't know why.Maybe you can try it.

Cardio answered 23/7, 2020 at 11:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.