在eclipse中为android项目创建jar [英] Create jar for android project in eclipse

查看:162
本文介绍了在eclipse中为android项目创建jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好所有如何创建我的项目的jar文件,在android中使用eclipse创建。我以这种方式完成了项目 - >右键单击 - >导出 - >选择构建器 - > antbuilder - >确定,然后在此过程之后,将使用 build.xml 被创建。在bulid.xml上,我将创建新的构建器。




  • 右键单击项目 - >属性 - >选择新建 - xml和您的项目路径,然后按确定,将创建新的构建器。

  • 现在从项目属性中选择该构建器,然后按OK。

  • 现在构建您的项目和您的jar将在bin文件夹中创建。



我已经遵循上述过程,但是在bin文件夹中找不到我的jar。我可以看到我的build.xml被创建,所有的进程顺利,但是没有创建jar。任何人可以告诉我如何做到这一点?



我的build.xml

 <?xml version =1.0encoding =UTF-8standalone =no?> 
<! - 警告:Eclipse自动生成的文件。
任何修改都将被覆盖。
要在这里包含用户特定的构建文件,只需在同一个
目录中创建一个处理指令<?eclipse.ant.import?>
作为第一个条目并再次导出构建文件。 - >
< project basedir =。 default =buildname =testtttttttttt>新新旗200新新新200新新新200新200新200新新新新旗新新200新新旗200新新200新新旗200新新新200新新200新新旗2001-4545:
< property name =debuglevelvalue =source,lines,vars/>
< property name =targetvalue =1.6/>
< property name =sourcevalue =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 =testtttttttt.classpath>
< pathelement location =bin / classes/>
< path refid =Android 2.2.libraryclasspath/>
< path refid =com.android.ide.eclipse.adt.LIBRARIES.libraryclasspath/>
< / path> X- 20045454545 X- 20045 X- 20045 X- 20045 X- 20045 X- 20045 X- 20045 X- 20045 X- 20045 X-
< mkdir dir =bin / classes/>
< copy includeemptydirs =falsetodir =bin / classes>
< fileset dir =src>
< exclude name =** / *。java/>
< / fileset>
< / copy>
< copy includeemptydirs =falsetodir =bin / classes>
< fileset dir =gen>
< exclude name =** / *。java/>
< / fileset>
< / copy>
< / target> X-4545 X- 20045 X- 20045 X- 20045 X- 20045 X- 20045 X- 20045 X- 20045 X-
< delete dir =bin / classes/>
< / target>
< target depends =cleanname =cleanall/>
< target depends =build-subprojects,build-projectname =build/>
< target name =build-subprojects/>
< target depends =initname =build-project>
< echo message =$ {ant.project.name}:$ {ant.file}/>
< javac debug =truedebuglevel =$ {debuglevel}destdir =bin / classessource =$ {source}target =$ {target}>
< src path =src/>
< classpath refid =testtttttttt.classpath/>
< / javac>
< javac debug =truedebuglevel =$ {debuglevel}destdir =bin / classessource =$ {source}target =$ {target}>
< src path =gen/>
< classpath refid =testtttttttt.classpath/>
< / javac>
< / target>
< target description =构建引用此项目的所有项目,有助于传播更改。 NAME = 集结refprojects/>
< target description =将Eclipse编译器jar复制到ant lib目录name =init-eclipse-compiler>
< copy todir =$ {ant.library.dir}>
< fileset dir =$ {ECLIPSE_HOME} / pluginsincludes =org.eclipse.jdt.core _ *。jar/>
< / copy>
< unzip dest =$ {ant.library.dir}>
< patternset includes =jdtCompilerAdapter.jar/>
< fileset dir =$ {ECLIPSE_HOME} / pluginsincludes =org.eclipse.jdt.core _ *。jar/>
< / unzip>
< / target>
< target description =使用Eclipse编译器编译项目name =build-eclipse-compiler>
< property name =build.compilervalue =org.eclipse.jdt.core.JDTCompilerAdapter/>
< antcall target =build/>
< / target>
< / project>


解决方案

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


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.

  • Right click on project -> properties --> select new -->give build.xml and your project path and press ok, new builder will be created.
  • Now select that builder from project properties and press ok.
  • Now build your project and your jar will be created in bin folder.

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?

My 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>

解决方案

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆