简体   繁体   English

在ant中引用外部.jar库以构建Android Java jar

[英]Referencing external .jar libraries in ant to build a Android java jar

(I am new to ant and I've scoured the web for solutions to this, but none of them seem to work for me.) (我是ant的新手,我在网上搜寻了解决方案,但似乎没有一个适合我。)

I am trying to reference an external .jar library in building with ant. 我正在尝试在使用ant进行构建时引用外部.jar库。 But, I receive errors such as: package [name] does not exist , next to the import [name] statement in the .java file 但是,我收到如下错误:.java文件中import [name]语句旁边的package [name] does not exist

In my build.xml, I have the following line, which references the folder where the external jar is stored: 在我的build.xml中,有以下行,该行引用了外部jar所在的文件夹:

<property name="lib.dir" value="libs"/>

When I remove references to the external jar, ant builds. 当我删除对外部jar的引用时,ant就会构建。 Right now, it just seems like ant is unable to find the external libraries, and I am not sure how to update the build.xml properly to reference these libraries. 现在,似乎ant无法找到外部库,并且我不确定如何正确更新build.xml来引用这些库。

如果需要编译中包含的jar,可以执行以下操作:

<javac srcdir="${src.dir}" destdir="${local.build.dir}" source="1.5" target="1.5" classpathref="base.classpath" debug="true">

Try removing this property entry and rebuilding. 尝试删除此属性条目并重建。 I have always had external library jars and it is always sufficient to add them in libs folder to get everything building successfully. 我一直都有外部库jar,将它们添加到libs文件夹中足以使所有内容成功构建总是足够的。

The reason why this property entry might be failing you is: the auto-generated build.xml references another build file in the android sdk tools folder. 此属性条目可能使您失败的原因是:自动生成的build.xml引用了android sdk tools文件夹中的另一个构建文件。 This other build file knows how to reference the libs folder of the project you are currently building, but from its perspective the path is not simply libs . 该另一个构建文件知道如何引用当前正在构建的项目的libs文件夹,但是从其角度来看,路径不仅仅是libs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM