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
targetis 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.
pathis the location of your project directory. If the directory does not exist, it will be created for you.
activityis the name for your Activity class. This class file will be created for you inside<path_to_your_project>/src/<your_package_namespace_path>/.
packageis the package namespace for your project, following the same rules as for packages in the Java programming language.
Output
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/- HoldsAnt-generated files, such asR.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 projectcommand 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--targetoption). Theandroidtool 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:
- Open a command-line and navigate to the root of your project directory.
- 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:
- Open a command-line and navigate to the root of your project directory.
- 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
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>

No comments:
Post a Comment