5

I'm supposed to create an SDK which will be easy to use, so I need it to be in a single jar file. Resources are problematic, but what about including ".so" files, which are NDK-created libraries (usually placed in "libs/armeabi" folder)?

Is it possible to add the ".so" files into the jar file, so that whoever uses the SDK's jar file won't need to add them to his libs folder in his project?

If so, how, and if not, is there any workaround?

To clarify: whoever uses the SDK should only use a single jar file, which will contain all that is needed in order to use the SDK, including the ".so" files.

Note that if I put the libs folder (and the ".so" files in it) into the project that uses the SDK, it works just fine. The same goes if I use the SDK project as an Android project.

halfer
  • 19,824
  • 17
  • 99
  • 186
android developer
  • 114,585
  • 152
  • 739
  • 1,270

1 Answers1

3

Actually it is what Android does since ADT 17 has come. As matter of fact, when your create a library project and you import it in another project, Android creates a jar file. This is true for native library too. Simple when you build your project library, the armeabi folder will be included in the jar too.

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
  • well that's exactly what i did . i'm using an android library and intend to give only the automatically created jar . however , even though the ".so" files are inside , it gives me this exception .it occurs when i set the libs folder as a source in the build path – android developer Jun 10 '12 at 15:23
  • weird . after making the libs folder as a source folder via the build path , i get a different error , this time on compilation time :"The library 'Library.jar' contains native libraries that will not run on the device." – android developer Jun 10 '12 at 15:27
  • i don't understand . they say there that it's impossible , no? – android developer Jun 10 '12 at 15:40
  • yes it does. And actually I had seen it works, import and load correctly the library. Maybe something has changed with the new adt? Now, mine, are only speculations . Maybe it does really not work – Blackbelt Jun 10 '12 at 15:42
  • it seems that they write that it worked in the past , but because of some people making weird mistakes , they disabled this feature . another link that shows this problem is: http://stackoverflow.com/questions/4882167/creating-a-product-sdk-how-do-i-add-a-native-lib-so-and-a-jar-with-the-sdk-i . seems like up to adt 12 (or less) it was possible , but no anymore. – android developer Jun 10 '12 at 15:57
  • when you say "yes it does" , what do you mean? that it is impossible , or that it's possible ? what adt do you have , and can you provide a sample project that shows that it still work? – android developer Jun 11 '12 at 08:16
  • when I said "yes it does" I mean that "the link says it is impossibile" – Blackbelt Jun 11 '12 at 08:27
  • do you still have it working for you ? i tried so many weird ways to accomplish it and it doesn't work on any of my trials . – android developer Jun 11 '12 at 08:32
  • maybe there is a way to do it via Ant ? sadly , i'm not experienced with it at all , and always rely on what adt gives me out of the box. – android developer Jun 11 '12 at 08:38
  • never used with Ant. Today, If I can, I will look for the test project and I will tell you if it works. – Blackbelt Jun 11 '12 at 09:48
  • Sorry dude. I can not now. I will try in few days. sorry again – Blackbelt Jul 19 '12 at 12:59