Recently, my blog has never been updated. The last time someone asked ant to compile the android project, I completed it here. If you think IDE is too slow or you think manual compilation is more cool, you can learn more without IDE. It is also a required course for becoming a cool man!
I. Prepare ant
Download from ANT Official Website
Http://ant.apache.org/
Ant environment Configuration:
1. Decompress the ant package to the local directory.
2. Set ant_home in the environment variable to your installation directory.
3. Add ant_home/bin to the path of your system environment.
For more information, I believe there are many
2. Detailed steps and instructions. here we need to know some Android commands.
If the android SDK environment has been configured, You can execute the android command in any directory. Otherwise, you must switch to the Android-SDK \ tools directory.
I have already configured it here, so no matter what path I am in.
1. Create an android Project
Parameter description:
-K/-- package: namespace (package name)-A/-- name Project Name
-P/-- path project-T indicates the version number of the Target Platform
C: \ Documents ents and Settings \ Administrator> Android Create Project-K com. Android. Ta
NK-a tank-T 4-p f: \ Tank
List the corresponding IDs of platforms of different versions. Android. Bat list targets/Android list
C: \ Documents ents and Settings \ Administrator> Android. Bat list targets
For an existing Android project, we can update it (modify the version of the platform) to automatically add ant configuration files such as build. xml.
C: \ Documents ents and Settings \ Administrator> Android update project -- name tank-T 11
-P f: \ Tank
Compile: directly ant does not have file output, so the parameters must be included later.
The ant parameter is as follows:
* Debug: Signature construction with debugging
* Release: Build an applicationProgramThe generated APK must be signed before it can be published.
* Install: Install and debug the build package to the running simulator or device;
* Reinstall
* Uninstall
Start to compile:
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: Non- able characters in ASCII encoding ********
The error "Warning: Non- able characters encoded with ASCII" is displayed.
Compilation garbled code solution:
View the output prompt:
[Setup] importing rules file: tools \ ant \ ant_rules_r3.xml
Find <sdkpath> \ tools \ ant \ ant_rules_r3.xml In the SDK directory.
Open the find node:
<Javac encoding = "ASCII" target = "1.5" DEBUG = "true" extdirs = ""...>
Change ASCII to GBK.
Start the corresponding simulator: emulator-AVD avdname
E: \ mylib \ Android \ androidant \ toast> emulator-AVD Tank
List existing avds
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.a
PK
OK. Compile android with ant and manually install the APK file. Is it cool!