7

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");
    }

Edric
  • 24,639
  • 13
  • 81
  • 91
  • can some one help me on it..?? – Muhammad Sabeel Ahmed Jan 06 '20 at 08:33
  • https://stackoverflow.com/questions/52515309/libraries-not-accessible-for-classloader-namespace-when-loading-dl4j-model-us did you check this thread – Edgar Jan 06 '20 at 08:35
  • @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. https://developer.android.com/about/versions/nougat/android-7.0-changes.html – Muhammad Sabeel Ahmed Jan 06 '20 at 09:45

2 Answers2

10

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.
user2891462
  • 3,033
  • 2
  • 32
  • 60
  • 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. – Brandon Ros Aug 14 '23 at 01:32
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.

WillWolf
  • 57
  • 6