Reputation: 490
I have looked for hours on the net but could not find an answer to the following question(s)... I have an android project that runs OK using "ant release" command line (for various reasons I cannot use Eclipse nor Android Studio, etc.) on MacOSX. I need to extend a 3rd-party class that consists in a jar file (called mididriver.jar). I added the following line in my main java source file :
import mididriver.*;
What do I need to add to my build.xml file and where should I put the mididriver.jar file in my project folder structure so that it does not give me a "package mididriver does not exist" error?
Many thanks (in advance) !
Here is the content of my build.xml which WORKS BEFORE I ADD the new class:
<project name="MyProject" default="debug">
<loadproperties srcFile="local.properties"/>
<loadproperties srcFile="project.properties"/>
<target name="clean" depends="android_rules.clean">
<delete dir="libs"/>
<delete dir="obj"/>
<exec executable="${ndk.dir}/ndk-build" dir="${basedir}" failonerror="true">
<arg value="clean"/>
</exec>
</target>
<target name="-pre-build">
<condition property="makefileConfig" value="Debug" else="Release">
<equals arg1="${ant.project.invoked-targets}" arg2="debug"/>
</condition>
<condition property="ndkDebugValue" value="NDK_DEBUG=1" else="NDK_DEBUG=0">
<equals arg1="${ant.project.invoked-targets}" arg2="debug"/>
</condition>
<condition property="app_abis" value="armeabi-v7a" else="armeabi-v7a">
<equals arg1="${ant.project.invoked-targets}" arg2="debug"/>
</condition>
<exec executable="${ndk.dir}/ndk-build" dir="${basedir}" failonerror="true">
<arg value="--jobs=2"/>
<arg value="CONFIG=${makefileConfig}"/>
<arg value="${ndkDebugValue}"/>
<arg value="APP_ABI=${app_abis}"/>
</exec>
<delete file="${out.final.file}"/>
<delete file="${out.packaged.file}"/>
</target>
<import file="${sdk.dir}/tools/ant/build.xml"/>
</project>
Upvotes: 0
Views: 847
Reputation: 490
Well, after many failures to try to define the lib folder, I put the jar file in the existing libs folder and now get a successful build...
Upvotes: 0
Reputation: 21152
Create a lib directory in your project
my-project
src
target
lib
Put the jar into the lib directory.
Modify the javac task to add the lib directory to the classpath.
<path id="lib.dir">
<fileset dir="./lib">
<include name="**/*.jar"/>
</fileset>
</path>
<javac srcdir="src" destdir="target/classes" >
<classpath refid="lib.dir"/>
</javac>
I don't know which target does not work for you. Is it javac? Or ndk-build? I don't know how to specify class path for ndk-build. There must be some option like -classpath
.
Upvotes: 1