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.
great !
ReplyDeleteThank You :)