android - Ant 构建脚本 : cannot find android. jar

标签 android ant build

你好,

我无法使用 ant 构建脚本编译我的项目。错误信息:

Ant cannot find symbol...

我阅读了有关创建 build.xml 的内容,但似乎还不够。我的项目目录具有以下布局:

项目

  • 来源
    • ...

libarie_with_needed_java.file

  • 来源
    • 客户
    • 助手

如何使用外部引用? Ant 找不到 android jarbuild.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>

我使用网站示例和 Eclipse 生成的文件创建了这个文件。

我删除了以下外部属性文件(以简化问题):

<property file="local.properties" />
<property file="build.properties" />
<property file="default.properties" />          

我需要包含来自不同 src 位置的外部 .java 文件。

我需要知道如何复制项目中的外部文件并将所有内容编译在一起。

谢谢, 马塞尔

最佳答案

属性文件通常包含在整个主构建脚本中使用的变量值。

要找出为什么找不到 android.jar,请执行以下操作:

  1. 浏览到包含 build.xml 的目录。
  2. 向上浏览一个目录 (../)。
  3. 向下浏览到 android-sdk-windows/platforms/android-4/
  4. 确保 android.jar 位于该目录中。

否则,您必须将路径更改为 android.jar 相对于 build.xml 文件的位置。

关于android - Ant 构建脚本 : cannot find android. jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3083450/

相关文章:

Android - 打开蓝牙设置,但在另一个 View 中

java - 异常 java.lang.NoClassDefFoundError : com. google.android.gms.common.AccountPicker

android - 渐变 ASCII : A problem occurred evaluating project ':app'

android - 如何将自定义适配器中的数组列表保存到 SharedPreference

java - Hibernate 工具无法从 Postgres 表中获取索引信息

java - 如何使用 Ant 接受可选的命令行参数?

ios - 未绑定(bind)变量命令 PhaseScriptExecution 失败,退出代码非零

java - 如何自动化 Intellij 项目配置

build - Eclipse CDT,同时构建静态库和共享库

C# - 发布.exe