如何使用ant4Eclipse构建Android项目?

时间:2011-10-10 18:04:18

标签: android android-build ant4eclipse

我正在尝试构建一个Android应用程序 - 以前只使用Eclipse构建 - 使用ant4Eclipse自动化构建。它有两个项目,一个是作为JAR构建的,另一个是APK(引用JAR)。这两个项目都引用了Android库。

所需的宏构建过程是:

  1. 构建JAR项目(称为XX)
  2. 将JAR项目导出到APK项目的lib文件夹
  3. 构建APK项目
  4. 现在,我只是想让JAR构建。我确信我会在第二个项目中遇到更多问题但是......一次只做一件事。这是我的 build.xml

    <project 
          name="XX"
    
           xmlns:ant4eclipse="antlib:org.ant4eclipse"
           xmlns:antcontrib="antlib:net.sf.antcontrib">
    
    <property environment="env"/>
    <property name="workspaceDirectory" value="${basedir}/.." />
    
    <taskdef uri="antlib:net.sf.antcontrib"
             resource="net/sf/antcontrib/antlib.xml" />
    
    <taskdef uri="antlib:org.ant4eclipse"
             resource="org/ant4eclipse/antlib.xml" />
    
    <import file="${env.ANT_HOME}/lib/a4e-jdt-macros.xml"/>
    
    <!-- This is here because ANT found this library reference in my project's .classpath and couldn't find it, so I added it thus -->
    <ant4eclipse:jdtClassPathLibrary name="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK">
        <fileset dir="C:\eclipse\eclipse-galileo\plugins">
          <include name="com.android.ide.eclpise.*.jar"/>
        </fileset>
    </ant4eclipse:jdtClassPathLibrary >
    <!-- I borrowed this from http://stackoverflow.com/questions/5649348/ant4eclipse-examples -->
     <target name="compileAndJar">
        <buildJdtProject workspacedirectory="${workspaceDirectory}" projectname="XX">
          <finish>
            <jar destfile="${jar.dir}/myjar.jar">
              <ant4eclipse:jdtProjectFileSet 
                  workspacedirectory="${workspaceDirectory}"
                  projectname="${buildJdtProject.project.name}"/>
            </jar>
          </finish>
        </buildJdtProject>
      </target>
    </project>
    

    现在这是我在运行 ant compileAndJar

    时遇到的错误
    BUILD FAILED
    C:\dev\Project\Client\Android\XX\build.xml:31: The following error occurred while executing this line:
    C:\bin\apache-ant-1.8.2\lib\a4e-jdt-macros.xml:77: The following error occurred while executing this line:
    C:\bin\apache-ant-1.8.2\lib\a4e-jdt-macros.xml:133: Reference buildJdtProject.boot.classpath.path not found.
    

    另请注意,我在构建输出中看到了这一点:

     [echo]   - bootclasspath      -> ${buildJdtProject.boot.classpath}
    

0 个答案:

没有答案