Android app unable to locate .so file bundled inside jar

576 views
Skip to first unread message

shashank admane

unread,
Sep 26, 2023, 10:38:20 AM9/26/23
to android-ndk
Hello Folks, 

I have couple of questions - 

1. I have compiled rust library (.so) on linux, will this work as it is in android app or do I need to compile it with specific android target? 

2. I have a jar added as library to Android studio. This jar contains .so file inside. I am loading this .so file using I am able to compile my app with this jar dependency. But when I run/launch app it crashes saying  -

Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: File /lib.so was not found inside JAR.

Any help is appreciated. 

Thanks,
Shashank

James Farrell

unread,
Sep 26, 2023, 12:26:55 PM9/26/23
to andro...@googlegroups.com
The .so file needs to be compiled for Android, preferably with the NDK. You also need different .so files for different architectures (arm, x86, etc.)

-- James


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/d20047b2-3969-4ace-943c-cf3837cb54c3n%40googlegroups.com.

enh

unread,
Sep 26, 2023, 12:29:29 PM9/26/23
to android-ndk

shashank admane

unread,
Sep 26, 2023, 3:24:06 PM9/26/23
to andro...@googlegroups.com
Thank you James for quick reply. Can you point me to any example/reference as in how to achieve this?
I have my own rust toolchain with which I could build .so and now to compile this for android targets what all things I need to do?

Also, is it doable via android studio? 

Thanks,
Shashan 




--
              
           Shashank !
 

 

shashank admane

unread,
Sep 26, 2023, 3:32:14 PM9/26/23
to andro...@googlegroups.com
Thank you enh for your prompt reply. Surely, I will take a look at above reference. 

How .so gets copied to android device? This .so is part of jar and I compiled android application with dependency on this jar. After successful build will .so gets bundled in .apk? Because after installing app, I don't see .so being available on device (I had to manually copy it to test my further code :-( ). I verified this via device explorer. Is there something I am missing here? 



--
              
           Shashank !
 

 

James Farrell

unread,
Sep 26, 2023, 4:05:59 PM9/26/23
to andro...@googlegroups.com
Rust is not officially supported, but take a look at https://github.com/jfgoog/android-rs-examples

-- James


shashank admane

unread,
Sep 26, 2023, 4:41:04 PM9/26/23
to andro...@googlegroups.com
Appreciate your help James. Thank you 😊 

Reply all
Reply to author
Forward
0 new messages