6

I have an android eclipse project and have generated the corresponding build.xml ant file by doing:

android update test-project -p . -m ..\main_project

This compiles fine. However, in eclipse I have then added three referenced external jars (easymock, objenesis and cglib). In eclipse everything builds fine but then when I run the above command again it doesn't add these jars to the classpath.

So my question is how to tell the build.xml to include these jars?

I have done some research first and some people suggested changing the rules files in the sdk itself but this is something I want to avoid as then everyone in my team would need to do this and that's not practical.

Thanks Stephen

steprobe
  • 1,659
  • 3
  • 17
  • 32
  • You can add jars to java classpath for android using eclipse as follows Right click on project > properties > Java Build path > Add External Jars. – Ashwin N Bhanushali Oct 11 '11 at 08:27
  • Follow this : http://stackoverflow.com/questions/1334802/how-can-i-use-external-jars-in-an-android-project/6859020#6859020 – Vinayak Bevinakatti Oct 11 '11 at 08:29
  • Hi, I added them successfully to the eclipse project and there is no problem. What I need to get working is the ant build.xml files for automation. – steprobe Oct 11 '11 at 08:48

3 Answers3

13

add jar.libs.dir=your_path_here/lib in ant.properties for SDK >=8

Taranfx
  • 10,361
  • 17
  • 77
  • 95
  • ... or your_path_here/libs which is the default for SDK 13. See the jar.libs.dir property in $SDK_DIR/tools/ant/build.xml. – Scott C Wilson Mar 29 '12 at 21:37
  • is this mandatory to have a sub folder named lib/ or libs/ in my custom lib directory. Should the path be relative to the build.xml file at the root of my project, or absolute ? – svassr Feb 12 '14 at 22:27
4

For build.xml you can set property "external.libs.dir" in one of your properties file( like build.properties), by default it points to libs/ folder of your project - simply put there all your jars

external.libs.dir=<your_custom_path>/lib
acm0x
  • 775
  • 6
  • 14
1

You should ideally use libs/ not lib, to remain consistent with Eclipse.

Joe Malin
  • 8,621
  • 1
  • 23
  • 18
  • Joe Malin is correct. libs/ is recommended by the android documentation. http://tools.android.com/recent/dealingwithdependenciesinandroidprojects – Mark F Guerra Mar 14 '13 at 19:18