Adding jar files to a project

Monkey Targets Forums/Android/Adding jar files to a project

Sub_Zero(Posted 2012) [#1]
Anyone know how to do this with a monkey project?

I've tried adding jars to the "libs" directory without any luck...

Or even adding java source code to be built (imported by modules) would do.


Sub_Zero(Posted 2012) [#2]
I also tried extracting to full sources to the src directory, but it is being deleted on each build...

The problem is, adding imports in a module won't compile if i add jar's in the libs dir of the project... now where do i put a jar file (or java source code) to be imported in my module?


Xaron(Posted 2012) [#3]
Have the same problem and no resolution yet. You have to alter the ANT xml build files to include more stuff.


Sub_Zero(Posted 2012) [#4]
The jar file i added to the libs directory, is actually being dex'ed into the final apk, althought to no use it seems...

seems like adding jars to the classpath at compile would do the trick... But where do you add that? (javac -cp jarfile.jar) .. ?
Maybe that will be the end of this:
[echo] Resolving Dependencies for MonkeyGame...
[dependency] Library dependencies:
[dependency] No Libraries


I hereby request a solution to this :) (pokeing mark)


Sub_Zero(Posted 2012) [#5]
Ok I found a temporary solution to the problem.

Which is having ant copy java source files to the src/ directory... Ant will do this every time you build...

Add this to your project's build.xml file (not the ant one):

Copy whole directory:
<copy todir="src">
  <fileset dir="libs/extjavasources/src"/>
</copy>


javac then compiles all the java files copied... It will work for using external sources with modules.


Xaron(Posted 2012) [#6]
Thanks for that! :)