Skip to content

Unable to load native library: /data/app-lib/*/lib*.so #446

@p0ryae

Description

@p0ryae

I managed to compile, get the .so file, and then package an apk based on it. However, no matter what I try, I keep getting this error over and over again. It just can't load the native library, even though it's compiled based on the device's architecture (armv6). I use the arm-linux-androideabi target in order to get the final lib .so file.

I use ndk r16b, which is the last ndk to support armeabi.

For compilation of the .so file, I pass through the CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER flag with the value of /home/porya/Android/Sdk/ndk/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld. Furthermore, I also link the libraries in the build.rs:

fn main() {
    println!("cargo:rustc-link-search=/home/porya/Android/Sdk/ndk/android-ndk-r16b/platforms/android-19/arch-arm/usr/lib/");
}

The full error report in adb logcat:

E/AndroidRuntime( 3363): FATAL EXCEPTION: main
E/AndroidRuntime( 3363): Process: org.p0ryae.trs24, PID: 3363
E/AndroidRuntime( 3363): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.p0ryae.trs24/android.app.NativeActivity}: java.lang.IllegalArgumentException: Unable to load native library: /data/app-lib/org.p0ryae.trs24-1/libtrs_24.so
E/AndroidRuntime( 3363): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2212)
E/AndroidRuntime( 3363): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2271)
E/AndroidRuntime( 3363): 	at android.app.ActivityThread.access$800(ActivityThread.java:144)
E/AndroidRuntime( 3363): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
E/AndroidRuntime( 3363): 	at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 3363): 	at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 3363): 	at android.app.ActivityThread.main(ActivityThread.java:5179)
E/AndroidRuntime( 3363): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3363): 	at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 3363): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
E/AndroidRuntime( 3363): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
E/AndroidRuntime( 3363): 	at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 3363): Caused by: java.lang.IllegalArgumentException: Unable to load native library: /data/app-lib/org.p0ryae.trs24-1/libtrs_24.so
E/AndroidRuntime( 3363): 	at android.app.NativeActivity.onCreate(NativeActivity.java:183)
E/AndroidRuntime( 3363): 	at android.app.Activity.performCreate(Activity.java:5231)
E/AndroidRuntime( 3363): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
E/AndroidRuntime( 3363): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
E/AndroidRuntime( 3363): 	... 11 more
W/ActivityManager( 2138):   Force finishing activity org.p0ryae.trs24/android.app.NativeActivity

I also tried checking the dependencies for libtrs_24.so using readelf and my android system has all of them.

Is there a way to find the root cause? Am I missing something? Any ideas on where to start is appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions