I am trying to write very simple tutorial to build Android APK using Ant tool. To build APK using eclipse is very easy, normally developer use it but in some specially senario you need to build APK using command line.
1. JDK :Install JDK and set JAVA_HOME
2. Android SDK :Download Android Platforms using Android SDK
3. Ant :Install Ant and set ANT_HOME
Now, Take your any project developed in eclipse or any other IDE. I am taking project from eclipse.
Step 1 : Copy your project folder from Eclipse Workspace to the Desktop
Step 2 : Create keystore file using keytool command
keytool -genkey -v -keystore
.keystore -alias -keyalg RSA -keysize 2048 -validity 365
Step 3 : Copy keystore file in your project folder
Step 4 : Create "ant.properties" file using any text editor, this file contain information about keystore file. create your keystore file `
key.store=MyAndroidApp.keystore key.alias=MAA key.store.password=kpbird key.alias.password=kpbirdStep 4 : Create "default.properties" file, If you have created project using eclipse, this file will available, If not create file with following content, change api level as per your project.
# This file is automatically generated by Android Tools. # Do not modify this file -- YOUR CHANGES WILL BE ERASED! # # This file must *NOT* be checked in Version Control Systems, # as it contains information specific to your local configuration. # location of the SDK. This is only used by Ant # For customization when using a Version Control System, please read the # header note. sdk.dir=/Users/kpbird/android-sdk-macosx
Step 6 : Create "build.xml" with following content, change project name "MyAndroidProject".
Step 7 : Now, It's time to start build, open terminal, go to the project folder and execute following command
ant releaseStep 8 : You APK file will be at following path.
Project Folder -> bin -> MyAndroidProject-release.apk
Create following files in your Project Folder and execute "ant release" command