为eclipse中的android项目创建jar

时间:2023-01-22 12:36:44

Hello all how can I create jar file of my project that is created in android using eclipse. I have done in this way project -> right-click->export --> select builder -->antbuilder-->ok then after this process build.xml will be created. On bulid.xml I will create new builder.

大家好,我如何创建我的项目的jar文件,这是用eclipse在android中创建的。我以这种方式完成了project ->右键->export -> select builder- >antbuilder- >ok,然后在这个过程构建之后。xml将被创建。在建造。xml I将创建新的构建器。

  • Right click on project -> properties --> select new -->give build.xml and your project path and press ok, new builder will be created.
  • 右键单击项目->属性->选择new ->生成。xml和您的项目路径和按ok,将创建新的构建器。
  • Now select that builder from project properties and press ok.
  • 现在从项目属性中选择构建器并按ok。
  • Now build your project and your jar will be created in bin folder.
  • 现在构建您的项目,您的jar将在bin文件夹中创建。

I have followed above process but my jar is not found in bin folder. I can see my build.xml is created and all process goes smooth but still jar is not created. Can any one tell me how can I do this?

我已经遵循了上面的过程,但是我的jar在bin文件夹中没有找到。我可以看到我的身材。xml是创建的,所有过程都是平滑的,但是仍然没有创建jar。有人能告诉我怎么做吗?

My build.xml

我的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>

2 个解决方案

#1


26  

In Eclipse, select project, right click on the project, Select Export, From that select Jar. Then follow the simple wizard and give the destination where you want to save your jar, and finish. You can find your jar there. 为eclipse中的android项目创建jar

在Eclipse中,选择project,右键单击项目,选择Export,从该选择Jar中。然后按照这个简单的向导,给出要保存jar的目的地,然后完成。你可以在那里找到你的罐子。

#2


1  

Step 1. Create Android library project as explained here.

步骤1。创建这里解释的Android库项目。

Step 2. Now you need to give reference of Android Library project created in step 1 to your client application. There are two ways to do so.

步骤2。现在,您需要为客户端应用程序提供第1步中创建的Android库项目的参考。有两种方法可以做到这一点。

•Give reference of Android Library Project itself by client app property -> Select 'Android' on left pane -> In Libraty Section, Add Android Libraty project (This is explained at link given in Step 1 above)

•通过客户端app属性为Android Library项目本身提供参考——>选择左侧面板上的“Android”——Libraty部分的>,添加Android Libraty项目(见上文第1步的链接)

•Give the reference of .jar file of Android Library project (from Location of Android Library project -> bin -> .jar file). Client Application -> Properties -> Click 'Java Build Path' in lefe pane -> Go to 'Libraries' Tab -> Click 'Add External JARs' button and select the .jar file -> Go to 'Order and Export' tab and select the added .jar file reference and move it to top.

•给出Android图书馆项目的.jar文件的引用(从Android库项目的位置-> bin -> .jar文件)。客户端应用->属性->在lefe窗格中点击“Java构建路径”->到“library”选项卡->点击“添加外部jar”按钮,选择.jar文件->进入“Order and Export”选项卡,选择添加的.jar文件引用,并将其移至顶部。

Hope this will help you

希望这能对你有所帮助

#1


26  

In Eclipse, select project, right click on the project, Select Export, From that select Jar. Then follow the simple wizard and give the destination where you want to save your jar, and finish. You can find your jar there. 为eclipse中的android项目创建jar

在Eclipse中,选择project,右键单击项目,选择Export,从该选择Jar中。然后按照这个简单的向导,给出要保存jar的目的地,然后完成。你可以在那里找到你的罐子。

#2


1  

Step 1. Create Android library project as explained here.

步骤1。创建这里解释的Android库项目。

Step 2. Now you need to give reference of Android Library project created in step 1 to your client application. There are two ways to do so.

步骤2。现在,您需要为客户端应用程序提供第1步中创建的Android库项目的参考。有两种方法可以做到这一点。

•Give reference of Android Library Project itself by client app property -> Select 'Android' on left pane -> In Libraty Section, Add Android Libraty project (This is explained at link given in Step 1 above)

•通过客户端app属性为Android Library项目本身提供参考——>选择左侧面板上的“Android”——Libraty部分的>,添加Android Libraty项目(见上文第1步的链接)

•Give the reference of .jar file of Android Library project (from Location of Android Library project -> bin -> .jar file). Client Application -> Properties -> Click 'Java Build Path' in lefe pane -> Go to 'Libraries' Tab -> Click 'Add External JARs' button and select the .jar file -> Go to 'Order and Export' tab and select the added .jar file reference and move it to top.

•给出Android图书馆项目的.jar文件的引用(从Android库项目的位置-> bin -> .jar文件)。客户端应用->属性->在lefe窗格中点击“Java构建路径”->到“library”选项卡->点击“添加外部jar”按钮,选择.jar文件->进入“Order and Export”选项卡,选择添加的.jar文件引用,并将其移至顶部。

Hope this will help you

希望这能对你有所帮助