Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Ant to compile Android projects

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to use Ant to compile Android project, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

One, prepare ant

Ant official website is available for download

Http://ant.apache.org/

Ant environment configuration:

one. Extract the ant package to the local directory.

two. Set ANT_HOME in the environment variable and set the value to your installation directory.

three. Add ANT_HOME/bin to the path of your system environment.

For more introductions, you can go to google. I believe there are many.

Second, detailed steps and instructions, here we need to know some Android commands.

The prerequisite is that the android sdk environment is configured, so you can execute the android command in any directory, otherwise you have to change to the android-sdk\ tools directory.

I've already configured it here, so no matter what path I'm in,

1. Create an android project

Parameter description:

-k /-- package is the namespace (package name)-a /-- name project name

-p /-- path project-t is the version number of the target platform

C:\ Documents and Settings\ Administrator > android create project-k com.android.Ta nk-a Tank-t 4-p F:\ tank

List the corresponding id numbers android.bat list targets / android list for different versions of the platform

C:\ Documents and Settings\ Administrator > android.bat list targets

For existing android projects, we can go to update (modify the version of the platform), which will automatically add ant configuration files such as build.xml

C:\ Documents and Settings\ Administrator > android update project-- name Tank-t 11-p F:\ tank

Compile: there is no file output for direct ant, so be sure to bring parameters later.

The ant parameters are as follows:

Debug: build release with trial signature: build an application, and the generated apk must be signed before it can be released

Install: install debug-built packages to running simulators or devices

Reinstall

Uninstall

Start the compilation:

E:\ MyLiB\ Android\ AndroidAnt\ MyBoardCastReciver > ant debug

Buildfile: e:\ MyLiB\ Android\ AndroidAnt\ MyBoardCastReciver\ build.xml

[setup] Android SDK Tools Revision 7

[setup] Project Target: Android 2.2

[setup] API level: 8

[setup]

[setup]-

[setup] Resolving library dependencies:

[setup]-

[setup] Ordered libraries:

[setup]-

[setup]

[setup] WARNING: No minSdkVersion value set. Application will install on all

Android versions.

[setup]

[setup] Importing rules file: tools\ ant\ ant_rules_r3.xml

[javac] * warning: unmapped characters encoding ascii *

"warning: unmapped characters encoding ascii" error occurred

Compile garbled solution:

View the output prompt:

[setup] Importing rules file: tools\ ant\ ant_rules_r3.xml

Find\ tools\ ant\ ant_rules_r3.xml in the sdk directory

Open the find node:

Just change ascii to gbk.

Start the corresponding simulator: emulator-avd avdName

E:\ MyLiB\ Android\ AndroidAnt\ Toast > emulator-avd tank

Make a list of existing avd

E:\ MyLiB\ Android\ AndroidAnt\ Toast\ bin > adb devices

List of devices attached

Emulator-5554 device

Install to the specified avd

E:\ MyLiB\ Android\ AndroidAnt\ Toast\ bin > adb-s emulator-5554 install Toast-debug.apk

Thank you for reading this article carefully. I hope the article "how to compile an Android Project with Ant" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report