Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android native lib not installed with APK

I've made an android library project that uses some native libraries.

I've made the jni wrapper and put the native libs (.so) in the libs// folders. The native libs are compiled using cmake, for armeabi, armeabi-v7a, x86 and mips.

I export this project to a jar and put this jar into a "normal" android project. I then export this project to an apk and can see that my libs are bundles into it.

However, when i install the apk, the libs corresponding to the device are not copied into /data/data/com.my.app/lib and obviously, running the app complains about not finding the libs (UnsatisfiedLinkError).

I've search through SO and everywhere i can but found no answer that solved my case.

i'm using Eclipse, btw

Thanks for your help

UPDATE

OK, i've read the doc in the ndk and seen the examples, and unfortunately, i can't see the solution.

The ndk build the c code into shared libs and places them into the appropriated location in the project. But it doesn't generate anything that says that the libs must be installed with the apk.

My goal is to provide an android library (so a jar), that can be included within an android application. I don't see the real difference between what i'm doing (compile the c libs using cmake and package the jni and java compiled classes into a jar) and what is done with android.mk

If you see what i'm missing, feel free to tell me (even if its obvious).

thanks

UPDATE

i've made a dirty hack: in the libs folder of my application, i've put the jar file containing my classes and my native libs and a copy of the .so files for each arch. Suprise, the libs are no installed in /data/data/com.me.myapp/lib

It seems to confirm that it's a packaging problem.

like image 328
florian Avatar asked Nov 28 '13 15:11

florian


1 Answers

I export this project to a jar and put this jar into a "normal" android project. I then export this project to an apk and can see that my libs are bundles into it.

The issue is that the Android packaging system doesn't handle with binary assets in JARs. For your application project to find and include the generated .so files, you need it to reference the library project as an 'Android library project': enter image description here

like image 131
user2424511 Avatar answered Sep 29 '22 18:09

user2424511