Ant (1): ant entry

Source: Internet
Author: User

Before reading this article, we assume that you have met the following conditions, otherwise reading this article will not help you much.
<1> JDK1.6 is successfully installed in ubuntu and environment variables are configured.
<2> the ant environment is successfully downloaded and configured in ubuntu.
<3> In ubuntu, the android-sdk is successfully installed, and the tools and platform-tools environment variables are configured.
Let's get started with ant's android development journey! /Home/mark/android/android-sdk-linux_x86 is the path to android_sdk installation.

1. android commands
Open the terminal and enter the command

Android-h
You can list the help and usage of this command. The following command is the focus of this article.

Create project: Creates a new Android project
Update project: Updates an Android project (must already have an AndroidManifest. xml)
Next, let's take a look at the parameters and usage of these two commands. Open the terminal and enter the command

Android-h create project
You can see that the output help information is:

Usage:
Android [global options] create project [action options]
 
 
Global options:
-V -- verbose Verbose mode: errors, warnings and informational messages are printed.
-H -- help Help help on a specific command.
-S -- silent Silent mode: only errors are printed out.
 
 
Action "create project ":
Creates a new Android project.
Options:
-N -- name Project name
-T -- target Target ID of the new project [required]
-P -- path The new project's directory [required]
-K -- package Android package name for the application [required]
-A -- activity Name of the default Activity that is created [required]
Similarly, you can look at the usage of another command.

Usage:
Android [global options] update project [action options]
 
 
Global options:
-V -- verbose Verbose mode: errors, warnings and informational messages are printed.
-H -- help Help help on a specific command.
-S -- silent Silent mode: only errors are printed out.
 
 
Action "update project ":
Updates an Android project (must already have an AndroidManifest. xml ).
Options:
-P -- path The project's directory [required]
-L -- library Directory of an Android library to add, relative to this project's directory
-N -- name Project name
-T -- target Target ID to set for the project
-S -- subprojects Also updates any projects in sub-folders, such as test projects.
2. Create a project
In the/home/mark path, create an android project. The details are as follows:
Project name: TestAntAndroidActivity
Name: TestActivity
Package name: mark. zhangandroid version: 4, that is, android1.5
In the terminal, you only need:

Android create project-k mark. zhang-n TestAntAndroid-a TestActivity-t 4-p/home/mark/TestAntAndroid
OK. The TestAntAndroid project directory will be created under/home/mark/. Its structure is as follows, which is the same as creating a project using Eclipse/ADT.
Modify the res/layout/main. xml file

<? Xml version = "1.0" encoding = "UTF-8"?>
<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Android: orientation = "vertical"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
>
<TextView
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: text = "this is my ant compile android app"
Android: textSize = "20sp"
Android: textColor = "# aa000a"
/>
</LinearLayout>
Tip: Run androidlist target to view the installed sdk version.
3. compile the project
You only need two simple commands!

Cd/home/mark/TestAntAndroid/
Ant debug
Go to the/home/mark/TestAntAndroid/bin directory and you can see the ak file:
4. Install apk
Install the above apk file to the simulator to verify whether it is feasible.

Cd/home/mark/TestAntAndroid/bin
 
 
Adb install TestAntAndroid-debug.apk
5. update existing projects
If the android project already exists, you can update the project (modify the version of the platform) to automatically modify ant configuration files such as build. xml.

Android update project-n TestAntAndroid-t 11-p/home/mark/TestAntAndroid/
Console display information:

Updated default. properties
Updated local. properties
File build. xml is too old and needs to be updated.
Updated file/home/mark/TestAntAndroid/build. xml
Updated file/home/mark/TestAntAndroid/proguard. cfg

Author: AndroidBluetooth

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.