记不住,于是原帖转过来,请看原帖:http://blog.csdn.net/ms03001620/article/details/8490238

一、生成build.xml

Eclipse中使用Ant为Android打包并且签名

SDK自带文件 在<sdk>tools/ant目录下这3个文件

其中build.xml和uibuild.xml中定义了大量基础构建方法和打包策略。我们只需要建立我们自己的build.xml并且存放在项目的根目录下,然后引用一下<sdk>tools/ant/build.xml即可。当然也可以拷贝它然后直接操作。

那么如何。以项目AntForAndroid为例。生成一个针对该项目的build.xml呢?

这里需要一个工具。就是SDK自带的android.bat .所在目录<sdk>tools/android.bat

然后通过命令行执行“android update project --path .”即可。完毕后即可通过android命令在当前项目目录下生成一个build.xml文件

新生成的3个文件 build.xml,local.properties,proguard-project.exe

二、配置ant.properties 

在项目根目录新建一个ant.properties文件(不要去改变他的名字,因为<sdk>\tools\ant\build.xml会引用到这个名字)

并且在里面写入一下数据:

#keystore文件的目录,因为在根目录下所以直接写名字了

key.store=android.keystore

#这个名字就是在生成keystore时那个alias字段的值

key.alias=android

#两个密码分别写建立keystore时的两个密码

key.store.password=(your pwd)

key.alias.password=(your pwd)

三、实现自动打签名apk

右键点击项目中的build.xml->run as... 先查看下有多少种任务,当然这些任务都是来自<sdk>\tools\ant\build.xml,项目里的只是引用了它

窗口打开

默认的选择在help上。打签名包的时候执行release这个任务即可。

按照以上的步骤配置好之后就能生成签名apk。并且大家可以通过学习<sdk>\tools\ant\build.xml来理解ant的基本奥妙。

最后在项目跟目录\bin下生成apk包

Ant是非常强大的。可以实现一下功能

例如

1.在生成apk的文件名里加上日期。

2.把apk文件自动通过邮件发给其他人。

3.apk文件上传服务器

等等

第二篇:http://www.xmumu.com/post/2011-11-22/7022215

通过Android命令自动编译出build.xml文件

用途: 做自动集成编译环境.

环境搭配我就不说了(SDK/环境变量等).
进入cmd界面.
进入项目目录.

输入: android.bat list target  来查询我们现有的版本list有哪些.

记住这个ID号码,下的代码面会用到.
输入: android update project -n ButtonDemo -t 1 -p E:\workspace\android\ButtonDemo

-n 对应的是项目名称
-t 就是我们之前查询的SDK版本对应的ID,大家根据自己的项目版本做出选择即可,我这个是android-8 所以用ID 1 .
-p就是生成的路径
成功后显示:

好了以下是生成的build.xml代码段:

<?xml version="1.0" encoding="UTF-8"?>

<project name="ButtonDemo" default="help">

<!-- The local.properties file is created and updated by the 'android' tool.

It contains the path to the SDK. It should *NOT* be checked into

Version Control Systems. -->

<loadproperties srcFile="local.properties" />

<!-- The ant.properties file can be created by you. It is only edited by the

'android' tool to add properties to it.

This is the place to change some Ant specific build properties.

Here are some properties you may want to change/update:

source.dir

The name of the source directory. Default is 'src'.

out.dir

The name of the output directory. Default is 'bin'.

For other overridable properties, look at the beginning of the rules

files in the SDK, at tools/ant/build.xml

Properties related to the SDK location or the project target should

be updated using the 'android' tool with the 'update' action.

This file is an integral part of the build system for your

application and should be checked into Version Control Systems.

-->

<property file="ant.properties" />

<!-- The project.properties file is created and updated by the 'android'

tool, as well as ADT.

This contains project specific properties such as project target, and library

dependencies. Lower level build properties are stored in ant.properties

(or in .classpath for Eclipse projects).

This file is an integral part of the build system for your

application and should be checked into Version Control Systems. -->

<loadproperties srcFile="project.properties" />

<!-- quick check on sdk.dir -->

<fail

message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'"

unless="sdk.dir"

/>

<!-- extension targets. Uncomment the ones where you want to do custom work

in between standard targets -->

<!--

<target name="-pre-build">

</target>

<target name="-pre-compile">

</target>

/* This is typically used for code obfuscation.

Compiled code location: ${out.classes.absolute.dir}

If this is not done in place, override ${out.dex.input.absolute.dir} */

<target name="-post-compile">

</target>

-->

<!-- Import the actual build file.

To customize existing targets, there are two options:

- Customize only one target:

- copy/paste the target into this file, *before* the

<import> task.

- customize it to your needs.

- Customize the whole content of build.xml

- copy/paste the content of the rules files (minus the top node)

into this file, replacing the <import> task.

- customize to your needs.

***********************

****** IMPORTANT ******

***********************

In all cases you must update the value of version-tag below to read 'custom' instead of an integer,

in order to avoid having your file be overridden by tools such as "android update project"

-->

<!-- version-tag: 1 -->

<import file="${sdk.dir}/tools/ant/build.xml" />

</project>

【转】Android项目使用Ant打包,生成build.xml的更多相关文章

  1. Android 自动编译、打包生成apk文件 3 - 使用SDK Ant方式

      相关文章列表: < Android 自动编译.打包生成apk文件 1 - 命令行方式> < Android 自动编译.打包生成apk文件 2 - 使用原生Ant方式> &l ...

  2. Android 自动编译、打包生成apk文件 2 - 使用原生Ant方式

    from://http://blog.csdn.net/androiddevelop/article/details/11100109 相关文章列表: <Android 自动编译.打包生成apk ...

  3. Android项目使用Ant多渠道打包(最新sdk)

    参考文章: http://blog.csdn.net/liuhe688/article/details/6679879 http://www.eoeandroid.com/thread-323111- ...

  4. Android 自动编译、打包生成apk文件 4 - 多渠道批量打包

    相关文章列表: < Android 自动编译.打包生成apk文件 1 - 命令行方式> < Android 自动编译.打包生成apk文件 2 - 使用原生Ant方式 > < ...

  5. android 用命令行打包生成 apk

    android 用 ant 进行 build. android sdk 下面的 tools/ant 下面的 build.xml 就是 build 的整个过程. 其中的 build 参数可在 ant.p ...

  6. vue项目通过webpack打包生成的dist文件放到express环境里运行(vue+webpack+express)

    1.首先需要的原料肯定是vue打包生成的dist文件 在vue项目目录下运行:npm run build,等待运行结束,会在项目目录下生成一个dist文件夹,里面会生成一些文件(如下图示) 小的项目文 ...

  7. 自动生成build.xml文件

    使用Eclipse 自动生成 Ant的Build.xml 配置文件,选择要生成Build.xml文件的项目,鼠标右键, Export-> General -> Ant Buildfiles ...

  8. [转]使用ant让Android自动打包的build.xml,自动生成签名的apk文件(支持android4.0以上的版本)

    在android4.0以后的sdk里那个脚本就失效了,主要是因为 apkbuilder这个程序不见了: 人家sdk升级,我们的脚本也要跟上趟,修改一下喽. 上网一查,大家的文章还停留在我去年的脚本程度 ...

  9. 项目打包文件build.xml

    Make命令其实就是一个项目管理工具,而Ant所实现功能与此类似.像make,gnumake和nmake这些编译工具都有一定的缺陷,但是Ant却克服了这些工具的缺陷.最初Ant开发者在开发跨平台的应用 ...

随机推荐

  1. 【php+uploadify3.2】上传按钮点击一点反应都没有,原因

    原因: 代码没有问题,这个原因也困扰我一段时间,是由于浏览器禁用了flash,需要放开,操作方法如下: 在谷歌浏览器输入:chrome://settings/content/flash 然后添加需要该 ...

  2. ios中core Plot (2)

    #import "ViewController.h" @interface ViewController () //指定要画得view @property(nonatomic,as ...

  3. Java交替打印两个字符串

    一.使用volatile关键字 public class Main { volatile int x = 0; Main() { new Thread(() -> { while (x < ...

  4. 搭建简单的网络部分(OC)框架

    准备工作 1.文件目录结构示图(按照MVC分层) 文件目录结构图/自定义Cell Controller: CYXOneViewController Model: CYXMenu View: CYXCe ...

  5. (转)失败和拒绝,也是一种肯定 找工作时,我四处碰壁这一段经历对自己职业生涯的帮助最大。为什么? "因为这些挫折让我的脸皮变厚了 如果你不是每天被人拒绝,那就说明你的人生目标不够远大 所谓成功,就是不停地经历失败,并且始终保持热情

    (转)失败和拒绝,也是一种肯定 昨天,先是看到一个老外,说了一句很震撼的话. "你个人的项目,应该有四分之一会失败,否则就说明你的冒险精神不够." (Expect and hope ...

  6. kubernetes架构之二

    一.概述 IaaS:即基础设施即服务,通过虚拟化和分布式存储等技术,实现对包括服务器.存储设备.网络设备等各种物理资源的抽象:从而形成了一个可扩展.可按需分配的虚拟资源池.最具代表性的IaaS产品有A ...

  7. 【SQL】SQL中Case When的用法

    Case具有两种格式.简单Case函数和Case搜索函数. --简单Case函数 CASE sex ' THEN '男' ' THEN '女' ELSE '其他' END --Case搜索函数 ' T ...

  8. block(四)揭开神秘面纱(下)-b

    看此篇时,请大家同时打开两个网址(或者下载它们到本地然后打开): http://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/BlocksRuntim ...

  9. C# Log4net根据日志等级输出到不同文件

    原文地址: Log4Net.Config <?xml version="1.0" encoding="utf-8"?> <configurat ...

  10. Git 配置(分布式版本控制系统)

    1.Mac Git 配置文件 既然已经在系统上安装了 Git,你会想要做几件事来定制你的 Git 环境.每台计算机上只需要配置一次,程序升级时会保留配置信息.你可以在任何时候再次通过运行命令来修改它们 ...