Take the 2-minute tour ×

I'm trying to build an app using a library packed in a JAR file.

When I call one of the functions I get this error:

Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing thelibrary.class

I've check the source code of the library and I think it crushes when loading some .so files ( System.loadLibrary("usb-1.0"); those files do exists in the JAR project under libs/armeabi (libusb-1.0.so)

I guess the .so files are not packed with the JAR, so how do I get them to be found in my project ?

(tried to copy them to libs/armeabi but the same exception is thrown....)

I do not get any link / build errors....


share|improve this question
Is "the JAR project" your own, or one from a third party? If "the JAR project" can be repackaged as an Android library project, NDK binaries work, as I've done that before: github.com/commonsguy/cwac-anddown –  CommonsWare Jan 7 '13 at 16:33
It is not my own, but I can view the sources for that project. should I recompile it ? –  Dani Jan 7 '13 at 17:15
Not so much "recompile" as repackage it as an Android library project. Then reference that Android library project from your app, instead of using the JAR. –  CommonsWare Jan 7 '13 at 17:17
Do you really have an android-compatible build of libusb? Which actually works, without root? More immediatley, the build tools do not really support .so's in JARs, so a key question would be if the .so is actually making it into the APK and onto the device. –  Chris Stratton Jan 7 '13 at 17:17
when I use the vendor example it works on device.... not rooted. –  Dani Jan 7 '13 at 18:32
show 2 more comments

1 Answer

up vote 1 down vote accepted

An ordinary JAR file will not work for distributing something that is dependent upon an Android NDK-compiled library. However, an Android library project can also distribute an NDK-compiled library.

but the real problem is that my app is going to be a library as well, and I don't know if I can make it a library while it is using other libraries

Assuming that "make it a library" == "make it an Android library project", this is fine, so long as projects attempting to use your library project also have access to the other library project.

share|improve this answer
add comment

Your Answer


