Ant构建脚本:无法找到android.jar
问题描述:
Hallo,Ant构建脚本:无法找到android.jar
我无法使用ant构建脚本来编译我的项目。错误消息:
Ant cannot find symbol...
我读到有关创建build.xml
,但现在看来,这是不够的。我的项目目录有以下布局:
poject
- SRC
- 根
- ...
libarie_with_needed_java.file
-
个
- SRC
- 客户
- 帮手
如何与外部引用的工作?蚂蚁找不到android jar
。该build.xml
文件如下所示:
<?xml version="1.0" encoding="UTF-8"?>
==================================================================== -->
<project name="test" default="main" basedir=".">
<!-- ====================================================================
Declare global properties for reuse and control of script
==================================================================== -->
<!-- For project source files -->
<property name="src.dir" location = "src/de/test"/>
<property name="common.link" location = "../test-common/common"/>
<!-- For compiled/output files. -->
<property name="build.dir" location = "build/source"/>
<!-- For class libraries and dependency files. -->
<property name="lib.dir" location = "lib"/>
<property name="sdk.dir" location = "../android-sdk-windows/" />
<!-- ====================================================================
Einstiegspunnkt - Target main
==================================================================== -->
<target name="main" depends="compile" description="getting started">
<echo message="start main target"/>
</target>
<!-- ====================================================================
Übersetzen - Target compile
==================================================================== -->
<target name="compile" depends="init">
<echo message="start compile target"/>
<javac srcdir="${src.dir}" destdir="${build}" debug="on"/>
<classpath refid="classpath"/>
</target>
<!-- ====================================================================
Initialisierungen - Target init
==================================================================== -->
<target name="init" description="create needed directories">
<echo message="start init target"/>
<mkdir dir="${build}"/>
</target>
</project>
我创建使用从网站的例子和月食生成的文件这个文件。
我已删除以下外部属性文件(为了简化问题):
<property file="local.properties" />
<property file="build.properties" />
<property file="default.properties" />
我需要包括从不同的位置的src外部.java文件。
我需要知道如何复制项目中的外部文件并将所有内容一起编译。
感谢, 马塞尔
答
属性文件通常包含为在整个主构建脚本使用的变量值。
要找出原因的android.jar无法找到,这样做:
- 浏览到包含
build.xml
的目录。 - 向上浏览一个目录(
../
)。 - 向下浏览到
android-sdk-windows/platforms/android-4/
。 - 确保
android.jar
位于该目录中。
否则,您将不得不将路径更改为android.jar相对于build.xml
文件的位置。
答
您可以使用SDK的位置定义一个名为sdk.dir的属性,但不要在build.xml文件中的任何其他位置使用它。
尝试在build.xml文件
<path id = "classpath">
<fileset dir = "${lib.dir}" includes = "*.jar"/>
<fileset dir = "${sdk.dir}" includes = "*.jar"/>
</path>
是的,它在里面,我觉得我做的假认为在build.xml – marcel 2010-06-21 09:55:38
@marcel添加此:使用Ant的echo任务(HTTP://蚂蚁.apache.org/manual/Tasks/echo.html)在脚本中显示变量的值。出于某种原因,JAR文件不会将其放入类路径中。 – 2010-06-21 10:00:19
感谢您的回复。 我想我包含sdk false或在build.xml中将其描述为false!请你能告诉我怎么做对吗? Marcel – marcel 2010-06-21 15:45:00