Driving Two Android Projects At Once

Posted: July 29, 2009 in Android, Java, Mobile
Tags: ,

Usually, when developing a java jar or NDK *so shared library you have two projects the main one where you do the apk and the other one where you develop the library. The targets I came up with:

<target name="javalib.compile" depends="clean">
		<javac encoding="ascii" target="1.5" debug="true" extdirs=""
			        <src path="${source-folder}" />
			        <!-- do not need genfolder -->
			           <fileset dir="${external-libs-folder}" includes="*.jar"/>
			           <pathelement path="${main-out-classes}"/>
		<!-- We package or jar in the same target -->
		<jar destfile="${dist}/javalib/${projectlib.java.projectname}.jar"
	<target name="javalib.move" depends="javalib.compile">
		<!-- run compile javalib -->
		<exec executable="ant" failonerror="true">
				<arg value="-f" />
			    <arg value="${projectlib.java.projectlocation}/android_build.xml" />
				 <arg value="javalib.compile"/>
	    <!-- move javalib to main project-->
		<copy file="${projectlib.java.projectlocation}/dist/javalib/${projectlib.java.projectname}.jar" todir="${basedir}/libs" />
	<target name="javalib.incremental" depends="javalib.move, compile">

This way I can point the IDE java builder to use this javalib.incremental target and thus have both projects incrementally compiled off of one target and thus have the javalib jar as input to my main project. I would imagine that you could set-up the NDK stuff the same way except you would be driving a target that drives an *.mk script to compile the *.so and move it before the main project compile task taking the *.so as input in the libs folder of main project.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s