views:

64

answers:

1

So I made a project with 2 source directories: one for actual code and the other for tests. It worked well in eclipse but then I decided to start using command line and the ant tool.

Android has a built-in function of generating build.xml, so I used the command 'android update project -p ProjectName'

This build.xml for installing works fine and I can run the application on the emulator. However, it only compiles the files from my source directory and the files from my test directory are not compiled. That means that I cannot run my unit tests from the command line and if I do I get class not found exceptions.

Is there any way to include another source directory so that it would compile my unit tests as well?

This is the build.xml that was generated (the rest is comments and not added here):

<?xml version="1.0" encoding="UTF-8" ?> 
<project name="ProjectNameActivity" default="help">
<property file="local.properties" />
<property file="build.properties" />
<property file="default.properties" />
<path id="android.antlibs">
<pathelement path="${sdk.dir}/tools/lib/anttasks.jar" /> 
<pathelement path="${sdk.dir}/tools/lib/sdklib.jar" /> 
<pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" /> 
</path>
<taskdef name="setup" classname="com.android.ant.SetupTask" classpathref="android.antlibs" /> 
<setup /> 
</project>
A: 

the ant task that compile your android program is not in the build file, it is imported.

you need to look in the android_rules.xml file that is imported by your build.xml.

There is a comment in the build.xml that explains how to override the imported compile ant target. Basically it instructs you to copy over the target and make the appropriate modifications.

Aaron Saunders
Yes, I found some other xml file that was actually being used to do all the work. So I guess I will just try to edit that one.
dominos
@dominos you should not edit that one since it is used for all of your projects. You should just copy the contents in to your build.xml file
Aaron Saunders
Actually I decided to make a separate android test project since it seems that android is meant to be tested like that. Now both the xml-files that were generated work correctly and I can run tests.
dominos