2012-07-02 46 views
11

創建Android項目罐子您好所有我該如何創建我的項目,該項目採用的是Android使用eclipse創建的jar文件。我已經以這種方式完成項目 - >右鍵單擊 - >導出 - >選擇建設者 - > antbuilder - >確定再經過這個過程的build.xml將被創建。在bulid.xml上,我將創建新的構建器。在Eclipse

  • 右鍵單擊項目 - >屬性 - >選擇新建 - >給build.xml和你的項目路徑,然後按確定,將會創建新的構建器。
  • 現在從項目屬性中選擇該構建器,然後按確定。
  • 現在建立你的項目,你的jar將在bin文件夾中創建。

我按照上面的過程,但我的罐子是不是在bin文件夾中找到。我可以看到我的build.xml被創建並且所有的過程都很順利,但仍然沒有創建jar。任何人都可以告訴我怎麼做到這一點?

我的build.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<!-- WARNING: Eclipse auto-generated file. 
       Any modifications will be overwritten. 
       To include a user specific buildfile here, simply create one in the same 
       directory with the processing instruction <?eclipse.ant.import?> 
       as the first entry and export the buildfile again. --> 
<project basedir="." default="build" name="testtttttttttt"> 
    <property environment="env"/> 
    <property name="debuglevel" value="source,lines,vars"/> 
    <property name="target" value="1.6"/> 
    <property name="source" value="1.6"/> 
    <path id="Android 2.2.libraryclasspath"> 
     <pathelement location="C:/Program Files (x86)/Android/android-sdk/platforms/android-8/android.jar"/> 
    </path> 
    <path id="com.android.ide.eclipse.adt.LIBRARIES.libraryclasspath"/> 
    <path id="testtttttttttt.classpath"> 
     <pathelement location="bin/classes"/> 
     <path refid="Android 2.2.libraryclasspath"/> 
     <path refid="com.android.ide.eclipse.adt.LIBRARIES.libraryclasspath"/> 
    </path> 
    <target name="init"> 
     <mkdir dir="bin/classes"/> 
     <copy includeemptydirs="false" todir="bin/classes"> 
      <fileset dir="src"> 
       <exclude name="**/*.java"/> 
      </fileset> 
     </copy> 
     <copy includeemptydirs="false" todir="bin/classes"> 
      <fileset dir="gen"> 
       <exclude name="**/*.java"/> 
      </fileset> 
     </copy> 
    </target> 
    <target name="clean"> 
     <delete dir="bin/classes"/> 
    </target> 
    <target depends="clean" name="cleanall"/> 
    <target depends="build-subprojects,build-project" name="build"/> 
    <target name="build-subprojects"/> 
    <target depends="init" name="build-project"> 
     <echo message="${ant.project.name}: ${ant.file}"/> 
     <javac debug="true" debuglevel="${debuglevel}" destdir="bin/classes" source="${source}" target="${target}"> 
      <src path="src"/> 
      <classpath refid="testtttttttttt.classpath"/> 
     </javac> 
     <javac debug="true" debuglevel="${debuglevel}" destdir="bin/classes" source="${source}" target="${target}"> 
      <src path="gen"/> 
      <classpath refid="testtttttttttt.classpath"/> 
     </javac> 
    </target> 
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/> 
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler"> 
     <copy todir="${ant.library.dir}"> 
      <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/> 
     </copy> 
     <unzip dest="${ant.library.dir}"> 
      <patternset includes="jdtCompilerAdapter.jar"/> 
      <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/> 
     </unzip> 
    </target> 
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler"> 
     <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> 
     <antcall target="build"/> 
    </target> 
</project> 
+0

Android可執行文件是一個.apk文件,爲什麼你需要一個jar文件? –

+4

在其他項目中使用 – unkown

+0

你可以在這裏添加你的build.xml嗎? –

回答

26

在Eclipse中,選擇項目,右鍵單擊該項目,選擇導出,從這個選擇JAR。然後按照簡單的嚮導,給你想要保存你的jar的目的地,並完成。你可以在那裏找到你的jar。 enter image description here

+0

感謝ü烏拉圭回合寶貴的幫助 – unkown

+0

@lenda:很高興爲您服務,隨時.. :) – YuDroid

+19

**的**替代。 如果您將項目標記爲庫項目,那麼jar文件會自動生成**。右鍵單擊項目選擇屬性,然後從左側選擇Android,然後選中「Is Library」,即可將項目設置爲庫項目。 然後檢查bin文件夾。如果jar不存在,請清理並構建項目。 – saji159

1

第1步。按照here的說明創建Android庫項目。

第2步:現在你需要給在步驟1到您的客戶端應用程序創建的Android庫項目的參考。有兩種方法可以做到這一點。

•通過客戶端應用程序提供的Android庫項目本身的參考 屬性 - >選擇在左窗格中的「安卓」 - >在Libraty部分,添加 的Android Libraty項目(這是在上述步驟1 給出的鏈接解釋)

•給Android Library項目的.jar文件引用 (從Android庫項目的位置 - > bin - > .jar文件)。在lefe 窗格>點擊「Java構建路徑」 - - 客戶端應用程序 - >屬性>轉到「庫」選項卡 - >點擊「添加外部JAR」按鈕,然後選擇 .jar文件 - >轉到「訂單和出口'選項卡,然後選擇 添加.jar文件參考並將其移至頂部。

希望這會幫助你