Monday, October 5, 2009

Android Application development from the command prompt without eclipse IDE

pre requirement

setting ur environment variable fot android sdk tool directory.

finding out the available target

android list targets.



you need to use the Ant tool and setting the ant environment



variable



setting the JAVA_Home directory for ant








project creating command




android create project --target 1 --path
./myProject
--activity MyActivity --package
com.example.myproject







  • target is the "build target" for your application. It corresponds to an Android platform library (including any add-ons, such as Google APIs) that you would like to build your project against. To see a list of available targets and their corresponding IDs, execute: android list targets.


  • path is the location of your project directory. If the directory does not exist, it will be created for you.


  • activity is the name for your Activity class. This class file will be created for you inside <path_to_your_project>/src/<your_package_namespace_path>/.


  • package is the package namespace for your project, following the same rules as for packages in the Java programming language.





Output



Fullscreen capture 1142009 114735 AM.bmp



Fullscreen capture 1142009 114959 AM.bmp



The tool generates the following files and directories:




  • AndroidManifest.xml - The application manifest file, synced to the specified Activity class for the project.


  • build.xml - Build file for Ant.


  • default.properties - Properties for the build system. Do not modify this file.


  • build.properties - Customizable properties for the build system. You can edit this file to overried default build settings used by Ant.


  • src/your/package/namespace/ActivityName.java - The Activity class you specified during project creation.


  • bin/ - Output directory for the build script.


  • gen/ - Holds Ant-generated files, such as R.java.


  • libs/ - Holds private libraries.


  • res/ - Holds project resources.


  • src/ - Holds source code.


  • tests/ - Holds a duplicate of all-of-the-above, for testing purposes.






updating project






android update project --target
<targetID> --path path/to/your/project/






If you're upgrading a project from an older version of the Android SDK or want to create a new project from existing code, use the android update project command to update the project to the new development environment. You can also use this command to revise the build target of an existing project (with the --target option). The android tool will generate any files and folders (listed in the previous section) that are either missing or need to be updated, as needed for the Android project.






Building Your Application



there are two option




To build in debug 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 debug



    This creates your Android application .apk file inside the project bin/ directory, named <your_DefaultActivity_name>-debug.apk. The file is already signed with the debug key.





Each time you change a source file or resource, you must run Ant again in order to package up the latest version of the application.







2.release mode





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 release mode:
    ant release



    This creates your Android application .apk file inside the project bin/ directory, named <your_DefaultActivity_name>.apk.



    Note: The .apk file is unsigned at this point. You can't install it on an emulator or device until you sign it with your private key.






Running Your Application




we r running on a emulator( android emulator can have many instance with specific Android platform with specific device configuration settings )



AVD control the emulator shape and size(The platform and configuration is defined with an Android Virtual Device (AVD))




to check the list of avd




C:\Documents and Settings\NexGT0016\
gpworkcmd\mycmd>android list avd
Available Android Virtual Devices:
Name: myand15
Path: C:\Documents and Settings\
NexGT0016\.android\avd\myand15.avd
Target: Android 1.5 (API level 3)
Skin: HVGA
Sdcard: 30M





to create new avd






C:\Documents and Settings\NexGT0016\
gpworkcmd\mycmd>
android create avd --name newavd1.5 --target 2
Android 1.5 is a basic Android platform.
Do you wish to create a
custom hardware profile [no]
Created AVD 'newavd1.5' based on Android 1.5

C:\Documents and Settings\NexGT0016\
gpworkcmd\mycmd>android list
avd
Available Android Virtual Devices:
Name: myand15
Path: C:\Documents and Settings\
NexGT0016\.android\avd\myand15.avd
Target: Android 1.5 (API level 3)
Skin: HVGA
Sdcard: 30M
---------
Name: newavd1.5
Path: C:\Documents and Settings\NexGT0016\
.android\avd\newavd1.5.avd
Target: Android 1.5 (API level 3)
Skin: HVGA





Launch an emulator






C:\Documents and Settings\NexGT0016\
gpworkcmd\mycmd>emulator
-avd newavd1.5
emulator: warning: opening audio output failed

emulator:emulator window was out of view
and was recentred





Fullscreen capture 1142009 124457 PM.bmp



emulator started



Install your application








C:\Documents and Settings\
NexGT0016>cd gpworkcmd

C:\Documents and Settings\
NexGT0016\gpworkcmd>cd mycmd

C:\Documents and Settings\
NexGT0016\gpworkcmd\mycmd>cd bin

C:\Documents and Settings\
NexGT0016\gpworkcmd\mycmd\bin>adb
install MyCMDActivity-debug.apk
45 KB/s (4389 bytes in 0.093s)
pkg: /data/local/tmp/MyCMDActivity-debug.apk
Success

C:\Documents and Settings\
NexGT0016\gpworkcmd\mycmd\bin>









Fullscreen capture 1142009 124944 PM.bmp







Fullscreen capture 1142009 125137 PM.bmp

No comments:

Post a Comment