"Go" Android Project using Ant package, generate Build.xml

Source: Internet
Author: User

Can't remember, so the original post turn around, please see the original post: http://blog.csdn.net/ms03001620/article/details/8490238

First, Generate Build.xml

Use ant to pack and sign Android in Eclipse

SDK comes with files in the <sdk>tools/ant directory of these 3 files

A number of basic building methods and packaging strategies are defined in Build.xml and uibuild.xml. We just need to build our own build.xml and store it in the root directory of the project, and then quote <sdk>tools/ant/build.xml. Of course, you can copy it and manipulate it directly.

So how. Take Project Antforandroid as an example. Build a build.xml for the project?

A tool is needed here. Is the SDK comes with the Android.bat. Directory <sdk>tools/android.bat

Then execute "Android Update Project--path" from the command line. Can. After completion, you can generate a Build.xml file in the current project directory via Android command.

Newly generated 3 files Build.xml,local.properties,proguard-project.exe

Second, the configuration ant.properties

Create a new ant.properties file at the root of the project (do not change his name, because <sdk>\tools\ant\build.xml will refer to this name)

and write a bit of data inside:

#keystore文件的目录, because in the root directory, I wrote the name directly.

Key.store=android.keystore

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

Key.alias=android

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

Key.store.password= (your pwd)

Key.alias.password= (your pwd)

Third, the realization of automatic signature apk

Right-click on Build.xml->run as ... in the project. First look at how many kinds of tasks, of course, these tasks are from the <sdk>\tools\ant\build.xml, the project only reference it

Window opens

The default selection is on Help. Do release this task when you are signing the package.

Follow the steps above to create a signature apk. And you can learn <sdk>\tools\ant\build.xml to understand the basic secrets of ant.

Finally, the APK package is generated under project and directory \ Bin

Ant is very powerful. can realize the function

For example

1. Add a date to the file name of the APK that was generated.

2. Automatically send the APK file to other people via email.

3.apk File Upload Server

Wait a minute

Article Two: http://www.xmumu.com/post/2011-11-22/7022215

Automatically compile the Build.xml file with android command

Purpose: Do automatic integration of the compilation environment.

Environment Collocation I will not say (sdk/environment variables, etc.).
Enter the CMD interface.
Enter the project directory.


Input: android.bat list target to find out what our existing version list is.



Remember this ID number, the next code face will be used.
Input: android update project-n buttondemo-t 1-p E:\workspace\android\ButtonDemo

- n corresponds to the project name
- T is the version of the SDK we previously queried the corresponding ID, people according to their own project version to make a choice, I this is android-8 so with ID 1.
- p is the generated path
After successful display:


Okay, here's the generated Build.xml code snippet:

<?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* is checked into

Version Control Systems. -

<loadproperties srcfile= "Local.properties"/>

<!--the ant.properties file can created by. It's only edited by the

' Android ' tool to the add properties to it.

The "the" to "change some Ant specific build properties.

Here is some properties 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 a integral part of the build system for your

Application and should is 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 is stored in ant.properties

(or in. classpath for Eclipse projects).

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

Application and should is 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 do in place, override ${out.dex.input.absolute.dir} */

<target name= "-post-compile" >

</target>

-

<!--Import the actual build file.

To customize existing targets, there is and 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-must update the value of Version-tag below to read ' custom ' instead of an integer,

In order to avoid have your file being overridden by tools such as "Android Update Project"

-

<!--version-tag:1--

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

</project>

"Go" Android Project using Ant package, generate Build.xml

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.