使用 默认sdk的ant build
参考: https://blog.51cto.com/techgogogo/1608441?source=drt
项目目录结构:
image.png添加okhttp
打开unbuild.xml
1、
原:
<!-- Compiles this project's .java files into .class files. -->
<target name="compile" depends="-build-setup, -pre-compile">
<javac encoding="${java.encoding}"
source="${java.source}" target="${java.target}"
debug="true" extdirs="" includeantruntime="false"
destdir="${out.classes.absolute.dir}"
bootclasspathref="project.target.class.path"
verbose="${verbose}"
fork="${need.javac.fork}">
<src path="${source.absolute.dir}" />
<compilerarg line="${java.compilerargs}" />
</javac>
</target>
改成:
<!-- Compiles this project's .java files into .class files. -->
<target name="compile" depends="-build-setup, -pre-compile">
<javac encoding="${java.encoding}"
source="${java.source}" target="${java.target}"
debug="true" extdirs="" includeantruntime="false"
destdir="${out.classes.absolute.dir}"
bootclasspathref="project.target.class.path"
verbose="${verbose}"
fork="${need.javac.fork}">
<src path="${source.absolute.dir}" />
<compilerarg line="${java.compilerargs}" />
<classpath>
<fileset dir="${jar.libs.dir}" includes="*.jar"/>
</classpath>
</javac>
</target>
2、
原:
<!-- Converts this project's .class files into .dex files -->
<target name="-dex" depends="compile, -post-compile">
<dex executable="${dx}"
output="${intermediate.dex.file}"
nolocals="@{nolocals}"
verbose="${verbose}">
<path path="${out.classes.absolute.dir}"/>
</dex>
</target>
改成:
<!-- Converts this project's .class files into .dex files -->
<target name="-dex" depends="compile, -post-compile">
<dex executable="${dx}"
output="${intermediate.dex.file}"
nolocals="@{nolocals}"
verbose="${verbose}">
<fileset dir="${jar.libs.dir}" >
<include name="okhttp-3.4.0.jar"/>
<include name="okio-1.9.0.jar"/>
</fileset>
<path path="${out.classes.absolute.dir}"/>
</dex>
</target>
注:要添加依赖的jar包
网友评论