我想使用 ant 构建几个引用相同 jar 文件的 android 项目。我不想将 jar 文件复制到项目中的每个 libs 目录中(由于源代码控制树的设置方式)。 answers我 find这里说“将它们放在 libs 目录中”并不能解决这个问题。
所以问题是,如何配置我的 android ant 构建脚本以引用项目外部单独目录中的公共(public) jar(不在“libs”中)?
最佳答案
在sdk中,tools/ant
下有ant文件。在 main_rules.xml
中,您可以找到以下代码部分:
<!-- Directory for the third party java libraries -->
<property name="jar.libs.dir" value="libs" />
<property name="jar.libs.absolute.dir" location="${jar.libs.dir}" />
<!-- create a path with all the jar files, from the main project and the
libraries -->
<path id="jar.libs.ref">
<fileset dir="${jar.libs.absolute.dir}" includes="*.jar" />
<path refid="project.libraries.jars" />
</path>
这就是 ant 构建代码确定从哪里获取 jar 的方式。您可以在 build.properties 中重载 jar.libs.dir
的值,因为这是在本节之前读取的,并且会重载该值。指向您打算使用的公共(public)目录将执行您的建议。您可能需要对其进行一些操作才能使其以您想要的方式工作。
需要注意的是,我不确定这是否会对其他构建生命周期 Activity 产生负面影响。
关于android - 如何引用公共(public)目录(不是库)中的外部 jar 文件来使用 ant 构建 android 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5312478/