KeepSafe/ReLinker

ReLinker fails to find dependencies recursively on Android-16

Opened this issue · 1 comments

Hello team, thanks for the project!

Trying to use it but can't seem to get it working on older Android devices.

I've put together a trivial test case to illustrate my issue.
It's an Android JNI project with min SDK set to 16 and Android STL set to "c++_shared".
Shared STL implies that my native library depends on libc++_shared.so.

I load my native library using:

ReLinker.recursively().log(logcatLogger).loadLibrary(getApplicationContext(), "native-lib");

Here's the output from logcat:

12-24 00:00:43.912 14207-14207/? D/---ReLinker: Beginning load of native-lib...
12-24 00:00:43.912 14207-14207/? D/---ReLinker: Loading the library normally failed: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1891]:  1124 could not load needed library 'libc++_shared.so' for 'libnative-lib.so' (load_library[1093]: Library 'libc++_shared.so' not found)
        at java.lang.Runtime.loadLibrary(Runtime.java:370)
        at java.lang.System.loadLibrary(System.java:535)
        at com.getkeepsafe.relinker.SystemLibraryLoader.loadLibrary(SystemLibraryLoader.java:24)
        at com.getkeepsafe.relinker.ReLinkerInstance.loadLibraryInternal(ReLinkerInstance.java:163)
        at com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary(ReLinkerInstance.java:136)
        at com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary(ReLinkerInstance.java:92)
        at com.viliussutkus89.relinkersharedstl.MainActivity.onCreate(MainActivity.java:34)
        at android.app.Activity.performCreate(Activity.java:5008)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
        at android.app.ActivityThread.access$600(ActivityThread.java:130)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4745)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system.NativeStart.main(Native Method)
12-24 00:00:43.912 14207-14207/? D/---ReLinker: native-lib (null) was not loaded normally, re-linking...
12-24 00:00:43.912 14207-14207/? D/---ReLinker: Beginning load of log...
12-24 00:00:43.912 14207-14207/? D/---ReLinker: log (null) was loaded normally!
12-24 00:00:43.912 14207-14207/? D/---ReLinker: Beginning load of m...
12-24 00:00:43.912 14207-14207/? D/---ReLinker: m (null) was loaded normally!
12-24 00:00:43.912 14207-14207/? D/---ReLinker: Beginning load of c++_shared...
12-24 00:00:43.912 14207-14207/com.viliussutkus89.relinkersharedstl D/---ReLinker: c++_shared (null) was loaded normally!
12-24 00:00:43.912 14207-14207/com.viliussutkus89.relinkersharedstl D/---ReLinker: Beginning load of dl...
12-24 00:00:43.912 14207-14207/com.viliussutkus89.relinkersharedstl D/---ReLinker: dl (null) was loaded normally!
12-24 00:00:43.912 14207-14207/com.viliussutkus89.relinkersharedstl D/---ReLinker: Beginning load of c...
12-24 00:00:43.912 14207-14207/com.viliussutkus89.relinkersharedstl D/---ReLinker: c (null) was loaded normally!

It works nicely if I load libc++_shared.so beforehand either manually by System.loadLibrary or using ReLinker, but that kind of defeats the purpose.

Failure happens on "system-images;android-16;default;x86" emulator image.
Works nicely on real (non-emulator) Android-25 device.

Let me know if I'm missing something obvious.

Thanks,
Vilius

Hi, any update on this issue? Related: gradle/gradle#23023