Skip to main content

Building Android Applications (.apk) from the Command Line



Creating an app directly from its source code and installing it on a device can often seem like a

daunting task. Take a look at how we make our Android applications with a few easy steps in the

command line!

Prerequisites:


1. Latest Android SDK

2. Latest JAVA JDK

3. Apache ANT

If you don’t have Ant, you can obtain it from the Apache Ant home page. Install it and make sure it is

in your executable PATH. Before calling Ant, you need to declare the JAVA_HOME environment

variable to specify the path to where the JDK is installed.

Also set the PATH to Android SDK

Pre Build Config:


1. Checkout the Latest Code from SVN

2. Navigate to Checkout Directory using Command Line (Terminal)

3. Enter the following command:

android update project -p <PATH TO CHKOUT DIR> -t "Google Inc.:Google APIs:<LEVEL Number>" -n <name that will appear in device>

example : android update project --name desired_apk_name --path .

4. To make sure everything is in place, type ant clean. This will make sure build.xml is proper

and all the required tools are in place.

There are two ways to build your application using the Ant build script: one for testing/debugging

your application — debug mode — and one for building your final package for release — release

mode.

Building in Release Mode

When you’re ready to release and distribute your application to end-users, you must build your

application in release mode. Once you have built it in release mode, it’s a good idea to perform

additional testing and debugging with the final .apk. Never publish an updated build to the Google

Play store.

To build in release mode:

1. Open a command-line and navigate to the root of your project directory.
2. Use Ant to compile your project in debug mode: ant release.

This creates your release .apk file inside the project bin/ directory, named <name of project>-

release.apk.

Android: How to set the name of the released APK?

Please First Change \android-sdk\tools\ant\build.xml for signed release apk

These changes are onetime in build.xml because of this file every time use with your project

build.xml to generate apk

<property name="out.final.file" location="${out.absolute.dir}/${ant.project.name}-

release.apk" />

By

<property name="out.final.file"location="${out.absolute.dir}/${ant.project.name}.apk"

/>

Installing the App on your Android Device or in the Emulator

Once <name of project>-release.apk is created you can install it on your Device or Emulator, to do

so follow the below steps:

1. Start the desired Emulator or Connect the Development Device

2. Navigate to /bin directory in your Project.

3. Enter adb install <name of project>-release.apk in the command line.

4. This will install the apk in Emulator or Device directly.

Comments

Post a Comment

Popular posts from this blog

What exactly means MVW design pattern ?

What is a MVW framework? The abbreviation stands for 'Model - View - Whatever'.  Well there are many different JavaScript frameworks available , all invented for the same purpose. They all try to separate the presentation logic from the business logic where JavaScript holds the model and logic, and html the presentation layer. Quick overview : You can change the model without changing the view and vice-versa Unit testing is easy These are the core benefits of using such a framework. By separating presentation and business logic changes to the code are easier to implement and take less time. Another benefit is that code can be reused from a controller thus saving more time. Angularjs makes the code also shorter in comparison to other frameworks, which improves code stability. Less code means minor potential for bugs. For several years +AngularJS was closer to MVC (or rather one of its client-side variants), but over time and thanks to many refactorings

File Upload & Download With ng-cordova File Transfer Plugin In Ionic Framework

Using the AngularJS extension set , ngCordova , with Ionic Framework and the Apache Cordova File Transfer plugin, you can easily upload files to a remote server and download files from a remote server. 1.Create the project ionic start Test blank cd Test ionic platform add android 2.Add Plugin org.apache.cordova.file-transfer https://github.com/apache/cordova-plugin-file-transfer This plugin allows you to upload and download files. This plugin defines global FileTransfer, FileUploadOptions Constructors. Although in the global scope, they are not available until after the deviceready event . Installation cordova plugin add cordova plugin add cordova-plugin-file-transfer     2.    org.apache.cordova.file             https://github.com/apache/cordova-plugin-file             This plugin implements a File API allowing read/write access to files residing on the    device.             Installation cordova plugin add cordova-pl

Steps To Create Cordova Plugin

Introduction A plugin is a package of injected code that allows the Cordova webview within which the app renders to communicate with the native platform on which it runs. Plugins comprise a single JavaScript interface along with corresponding native code libraries for each supported platform. Due to following reason, we will go for plugin development To get the native capabilities of the device in the cordova based app Build the common functionality across the number of Cordova application(Reusability) Prerequisites For the creation of plugin you need to install plugman . npm install -g plugman Plugin Structure Decide Plugin ID & Name The plugin ID should be unique Plugin name should follow the convention “cordova.plugin.[your.plugin.name]” Create the structure Use the following command to create the plugin with plugin ID “cordova.plugin.test” and name “Test”. plugman create --name Test --