How to compile the android project?
The following is a clear explanation of how to compile the android project in this official document,
I will not talk about too many detailed explanations, rtfm.
What I need to say is that we can allow the IDE to complete compilation for you, or compile the project using the command line method.
What? Command Line? Is it too old?
No! There is always a situation where ide cannot complete compilation. What is the situation?
When your resource files are very large, IDE is on strike. What should I do? Command line to help you.
Previously, we encountered this embarrassing situation in the e-book project melonpan.
Because the program contains a large font, pre-installed books and other resource files (about 100 m +), so when using eclipse for project compilation. Either eclipse will report a memory overflow error, or the crash will be dropped without sound.
So how to compile the project? We thought of the official document about the compilation project.
Thank God there are powerful tools like ant to help us do this.
Ant is a magic horse thing?
First, ant is not an "ant", but an abbreviation of "another neat tool.
It is a tool that automates software compilation, testing, deployment, and other steps. It is mostly used for software development in the Java environment. --- Wikipedia
Official Website: ant Official Website
How to Use ant to compile Android projects?
For the android project, an ant compilation build configuration template has been written in the SDK, which makes it easy to compile the android project using ant.
What should I do?
There are three major steps:
1. Prepare the environment and configure the environment variables.
2. Update the project and automatically generate the ant compilation configuration file
3. compile the project
Prepare the environment and configure Environment Variables
Download the latest ant package from the official website.
Then, add ant's <ant_root> \ apache-ant-x \ bin to the environment variable path (if you want this setting to be effective immediately, you need to log on to the current logout user and then log on again)
In this case, you can enter ant in the command line to test whether the above operations have been completed. If "buildfile: Build. XML does not exist!" is displayed! Build failed "indicates that the above settings have been completed, but the current directory does not have a configuration file for build. xml compilation to guide ant to complete the following operations.
What we need to do below is to use the existing tools to generate the ant compilation configuration file
Update the project to automatically generate ant
Compile the configuration file
android update project -p .
Compile the project
Compile the debug APK:
ant debug
Compile the release APK:
ant release
Tips
1. Compile the signature APK
Create the ant. properties file under the root path of the project, and configure some necessary parameters for the APK signature in the file. After compilation, the APK is signed!
Ant. properties file template:
key.store=path/to/my.keystorekey.alias=mykeystore
For more tips, refer: