开发者

Adding prebuilt library to android apk

I have built a dynamic library in android using android build system. This library provides jni interface for functions inside it. Now I want to include this library in an application (.apk). I am using eclipse for application development. Now, how can I use the prebuild dynamice library (.so) in my application ? I tried putting it in a lib folder in my applic开发者_JAVA技巧ation but it is not working.

Any pointers are appreciated.

I am not using ndk to build my .so.


Since you write 'so' I think you're using NDK. If you're using NDK I don't know the answer.

If you're using the "Java" SDK, then in your library project go to Properties -> Android, and Check "Is Library". In your "apk" project, go to Properties -> Android -> Add . And your Library project should be available.

Also, any Library added in the "Java Build Path" Menu (again, in project properties) should be available in the APK in the end.


I know it's slightly old, but have you checked in the built APK to see if your .so library is there? Should be in the libs/armeabi folder.

Also, your .so file should be in lib/armeabi folder in your eclipse solution. I'm guessing the armeabi bit depends on which processor your .so file is build for.

Also, I know that if your library isn't called lib[name].so, it won't get copied when the apk is installed on the device. So:

  • libfoo.so copies
  • foo.so doesn't copy

foo.so doesn't copy

Also, you can use DDMS (its a view in eclipse) and it's file explorer to see if it's been copied to your device. It should be under data/data/[packagename]/lib.

Hope this helps a bit!

Andy.


I hit this same problem while building Qiqqa for Android. Under your eclipse android project, make sure you have a libs directory (not that it is plural libS not singular lib). Inside that create the armeabi/etc subdirs with their respectibe .so files.

Then when you build, eclipse will automatically pick up this libs directory and create the corresponding lib in your apk. System.loadLibrary("XXX") will then resolve to libXXX.so on your correct architecture...

Cheers, Jimme

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜