1

I have a Android Project which is running fine on command line as well as using eclipse. So now I created the test project for the same, currently it is dependant on one external JAR. I kept this jar in libs/ directory. I can build and run the test project from command line.

Now the problem is that Eclipse is not able to recognize the JAR placed in libs directory and so eclipse is not able to build the project. I tried to modify build.properties file (setting the libs path in it), but that does not helped me.I don't want use properties ->JAVA build path -> Libraries -> Add external JARS in eclipse

Can some one tell the exact steps to build the test project with command line as well as with eclipse . Also, can I keep the JARs on another location than project directory ?

I don't want to use Maven

Sachchidanand
  • 1,291
  • 2
  • 18
  • 35
  • check this link and build............. http://stackoverflow.com/questions/2472059/cant-build-and-run-an-android-test-project-created-using-ant-create-test-projec – diyesh Sep 13 '11 at 13:29
  • Thanks diyesh for quick reply. I saw that link previously also. But that does not solved my problem. I can build my project smoothly on terminal but eclipse gives me error. It is not able to find the Robotium jar – Sachchidanand Sep 13 '11 at 13:42

1 Answers1

0

I encounter a similar problem with the following configuration:

MainProject
-src
 -...
-libs
  -ok.jar

TestProject
-src
 -testFiles

The ok.jar file is both needed by the MainProject and the TestProject

If I add the jar into TestProject/libs/ok.jar the build fail cause of class duplication. If I reference the MainProject/libs/ok.jar file threw external jar into the properties of the TestProject it does not work either.

I finally modified the properties of the MainProject to make it export the ok.jar file to other project by checking the combobox:

Project Properties -> Java Build Path -> Order and Export -> check the ok.jar file.

Last, the TestProject reference the MainProject as "Required projects on the build path".

Now the test project can see and use the ok.jar file.

It works fine threw eclipse and ant.

ol_v_er
  • 27,094
  • 6
  • 48
  • 61
  • but I dont want to refer my jar in this way "Project Properties -> Java Build Path -> Order and Export -> check the ok.jar file " – Sachchidanand Nov 01 '11 at 06:20
  • because, I m working in a team, and if I set path like that then every has to do the same thing. Which I dont want. And another thing is that , if I have set the path in build.xml then why android is not able to understand it ? – Sachchidanand Nov 02 '11 at 09:43
  • 1
    Ant build does not use the same build system as Eclipse. Thats why it works in command line but not in Eclipse. Unfortunately I don't know how to solve you problem in a proper way. Could you just not commit the modified classpath file and keep it local to make the build in Eclipse work? – ol_v_er Nov 03 '11 at 14:50