1

I've already seen similar questions to this on stackoverflow before, but I've been unable to find a solution to my particular problem. What I am wanting to do is add multiple external jar files to an android project that I can build either in eclipse or from a command line, and have the jar files bundled into the apk, so that the program will run on a device correctly.

I am finding that if I simply add all of my external jars to my project by putting them in the .classpath text file, and declaring them for export, then although my program compiles fine, the resulting apk does not contain the jar files, and running it on the device results in a noclassdeffounderror.

The solution in the answer to 2694392 wouldn't really work for me, because if I have to put the jar files in the project's own libs directory, then I will end up fighting with how the source control tree is set up... plus, it is rather annoying to have to manually copy jar files into a local folder that I've already tried to say were external in the first place. Ideally, the build system should copy any external jar files to the places that the runtime expects them to be all by itself. me. In reality, it seems like my question is most similar to that of the poster of question 5312478, but if I must overload the value of jar.libs.dir to refer to where I might keep the jar files, as suggested in the answer to that question, then I cannot easily import different jar files from different directories.

I have a general sense that a solution which copies all external jars from their necessary locations to the necessary libs folder as one of the phases before it fully packages up the apk might be adequate, but being something of a novice with ant, I'm not sure exactly what to put in the custom-rules.xml file such that the script itself does not have to know specifically which jars I am wanting to include (ie, they are all listed out in a single property or something)

Thank you so much in advance for any assistance you can offer.

*edit: Although certainly all attempts to be helpful are immensely appreciated, I would encourage people who may be considering answering this question with something similar to what has been answered elsewhere on stackoverflow to briefly reread above why the answers to the similar questions I have mentioned above are not entirely applicable to my question. Thank you.

Community
  • 1
  • 1
markt1964
  • 2,258
  • 1
  • 17
  • 42

1 Answers1

1

Put your jar files under libs folder, Android Developer tools will take of the rest.

Once you put your jar files into libs, clean and build project. You should be able to use your classes in your java program.

Meghal Shah
  • 405
  • 2
  • 10
  • Thank you, although as I had endeavored to describe above, I have already looked through the answers given to similar questions on stackoverflow, and this was the answer for question [http://stackoverflow.com/questions/2694392]. This answer would require that a) I fight with the way the source control tree in the project is set up (which I did not administrate), and b) have to remember to always manually copy all of what are alledgedly **external** jar files into the project's own folder if or when the jars gets updated. – markt1964 Jan 24 '13 at 14:57