Skip to content

Bundling with "libc++_shared.so" #27

Description

@kwek20

Hi!

Ive been trying to use cargo ndk with a bigger rust library.
The library is generating Java JNI bindings through a generator called "flapigen". (So its not a direct cmake project)
After building the APK with gradlew aR, which triggers gradlew jar (For making the Java side of the generated bindings) and a gradle task for running cargo ndk -t ${arch} -o ${libsPath} build --release.

Yea.. a bit of a trip :D But in the end the APK gets generated, and properly links with the generated jar.
When i install the APK, it also loads the native library correctly, however, one of the native parts needs libc++_shared.so (for i think a rust dependency, im in a bit over my head!).

According to .. the internet it should compile with that .so when i set APP_STL:=c++_shared in Application.mk, or

android {
    defaultConfig {
        ...
        externalNativeBuild {
            ndkBuild {
                arguments  "-DAPP_STL=c++_shared", "-DANDROID_TOOLCHAIN=clang"
            } 
        }
    }
}

However, inspecting the APK, it doesnt have it incuded.

The error: Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found: needed by /data/app/~~1wFPIY2YxMCnGcnEq7pBpA==/org.example-MjRM-ZMHEp1x9fjGfZEjrA==/base.apk!/lib/arm64-v8a/libexample_java.so in namespace classloader-namespace.
Ive tried building on NDK 20, 21 and 23, and targeting SDK 27, 28 and 29 to no avail.
Using gradle-6.7.1, if it makes a difference

        classpath 'com.android.tools.build:gradle:4.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31"

Any pointers you can give me?
Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions