8

It seems to me that gradle Android plugin does not include versioned .so libraries into .aar archive.

My case: I need to load some library in Android application that requires another library: libz.so.1

I do have libz.so and libz.so.1 in my native libraries directory.

After running gradle there is only libz.so library in created .aar archive. It results in java.lang.UnsatisfiedLinkError: dlopen failed: library "libz.so.1" not found exception when I try to run my application.

It looks like my otherlibrary tries to load only that specific version of libz.

readelf -d otherlibrary.so also tells me that it wants specific library: 0x00000001 (NEEDED) Shared library: [libz.so.1]

Both libraries that I want to load are third party libraries. It looks like I need to find a way for one of the following:

  • pack libz.so.1 into .aar archive, so otherlibrary.so could easily link with it
  • load libz.so and somehow make otherlibrary.so to link with it

but I'm running out of ideas, how to do it.

Part of build.gradle that builds .aar archive:

sourceSets {
    main {
        jniLibs.srcDirs = ['libs']
    }
}

libs directory contains both libz.so and libs.so.1 libraries. Only libz.so is assembled into .aar file.

This page: https://developer.android.com/studio/projects/android-library#aar-contents suggests me that only /jni/abi_name/name.so pattern is supported.

Looking forward for some help.

RustyChicken
  • 133
  • 1
  • 7
  • 1
    If your `otherlibrary.so` was originally compiled using Android NDK, i don't think it should have the reference like `xxx.so.1`. Hence, probably you need to have a proper `otherlibrary.so` first. – shizhen Mar 12 '19 at 01:29
  • 1
    https://stackoverflow.com/a/53137079/8034839 – shizhen Mar 14 '19 at 01:26
  • So the only solution was to rebuild zlib, so its SONAME would be libz.so, not libz.so.1 Thank you. – RustyChicken Mar 15 '19 at 14:51

0 Answers0