Get the Cricket widget and many other great free widgets at Widgetbox! Not seeing a widget? (More info) <!-- DMgPqbn97des3UYFj0Ohfw887qs --> The Android Programmer's Heaven: Android Project Compilation,Execution and Installation

Monday, February 13, 2012

Android Project Compilation,Execution and Installation


So till now we got to know about the Android Project creation. Now next thing i want to keep in front of you is how android projects are compiled and executed.

Android Project Compilation,Debugging and Execution
  So I will give you detailed description about this diagram.
1) First of all every Android project must have one Auto-Generated file R.java. This file contains a List of All the attributes we have used in our android Project and a Corresponding Hexadecimal Value. It also contains a Hexadecimal value of main(layout) and app_name(string). We can find this file in Project_Name/gen/package_name/R.java. This file shouldn't be removed otherwise an Android Project will not Work.
2) Secondly, this R.java file along with Application Source Code(.java Files) and Java Interfaces and alternatively .aidl files(Android Interface Definition File) are compiled with JAVA Compiler to create Class Files(Object Code).
3)After compilation step, a .dex file is created that is understandable to Dalvik Virtual Machine only( We won't use JVM here).
4) This compilation step we need not to take care of, We need to Debug this application with Apache ANT (Debug,Release) mode; generally we prefer Debug mode because this mode automatically assign Signed,align key with the Package so that it can be installed directly. If we Use Release mode , We need to manually assign the align key using Zip-align. the Debugging is done inside Root directory where build.xml file is located and command is:
ant debug
5) Now apkbuilder is used to create the corresponding .apk file and alignment and signed key is given using zipalign and now the project is ready to install on a Mobile Device or and Android Emulator.
6) To install this, go to project root directory and bin folder where your .apk file is located  and type on the command line:
adb install project_name-debug.apk

So we are done with the Compiling,debugging and installation phase.

No comments: