Android Application Development

Getting started with Android development


The best place to start is with the Android developers guide:
http://developer.android.com/guide/index.html
Application Fundamentals section
http://developer.android.com/guide/topics/fundamentals.html
This provides a good grounding in how Android works.
Developing the Android Apps
Eclipse
The only IDE with a decent Android plugin is Eclipse. The ADT plugin is supported by Google.
Netbeans does have an open source (6.x) plugin called nbandroid but it’s immature and lacks the following capabilities:
  • Device Manager (including sdcard loading)
  • Debugging
  • Profiling
  • Manifest editor
  • Wizards for new activites, resources etc
Installation
Installing Eclipse
Unzip Eclipse 3.5 to a local directory:
C:/Program Files/Project/Eclipse/eclipse-SDK-3.5-win32.zip
Edit the eclipse.ini file in the eclipse home directory:
\-startup
plugins/org.eclipse.equinox.launcher_1.0.200.v20090520.jar
\–launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
\-showsplash
org.eclipse.platform
\–launcher.XXMaxPermSize
512m
\-vmargs
\-Xms256m
\-Xmx512m
Installing Android
Unzip the Android SDK to a local directory (e.g. C:\AndroidProj):
Add the installation path to your PATH.
Run the “SDK Setup” tool found in the android sdk installation directory
Once in the SDK Setup tool, go to Settings and tick the option “Force https:// resources to be fetched using http://”
Then click on Available Packages, and select and install “SDK Platform Android 1.6, API 4″ and “SDK Platform Android 2.1, API 7″
This will download Android Platforms in the installation directory (eg: C:\AndroidProj\android-sdk-windows\platforms\android-4). This is the location you need to set the ANDROID_HOME property in your eclipse environment.
Using the same “SDK Setup” tool, you can create an Android Device (will need to create at least one for running in the emulator).
Creating Android Device
Currently we’re using 2 device profiles – one for the HTC Android 1.6), and one for the Google Nexus One (Android 2.0)
Select Virtual Devices
Click New to create AVD
Installing the (Android) ADT Plugin for Eclipse
To install the ADT plugin
Start Eclipse, then select Help > Install New Software….
In the dialog that appears, next to “Work With: ” enter the Location: xx and click Add
Tick “Developer Tools” (Andorid DDMS & Android Development Tools will then be selected) and click Next.
Read and accept the license agreement, then click Finish.
Wait for download and installation and then restart Eclipse.
Now modify your Eclipse preferences to point to the Android SDK directory:
Select Window > Preferences… to open the Preferences panel (Mac: Eclipse > Preferences).
Select Android from the left panel.
For the SDK Location in the main panel, click Browse… and locate your downloaded SDK directory. (ie: C:\AndroidProj\android-sdk-windows)
Click Apply, then OK.
Add platforms to the Android SDK
Start the Android SDK and AVD Manager from Eclipse -> Window > Android SDK and AVD Manager
Select Available components in the left panel.
Select SDK Platforms API4, 5, 6 & 7, and the corresponding Google APIs.
Click Install Selected
Verify all of the packages
Click Install Accepted
You need to define variables ANDROID_HOME inside eclipse to match your local env:
Inside Eclipse: go to Windows, Preferences, Java, Build Path, Classpath Variables and add
ANDROID_HOME (ie: C:\AndroidProj\android-sdk-windows\platforms\android-4)

Import Projects
To open the projects in Eclipse:
Start Eclipse, the select File > Import…
Select General > Existing Projects into Workspace
Click Next
Enter the Root directory where the projects were checked out
Check all projects
Click Finish
Build Projects
Eclipse builds each project after files are edited.

Cleaning:
Cleaning a project also forces Eclipse to rebuild. You can clean all projects by selecting Project, Clean…, Clean all projects, OK.
Each time you make a change to a project Eclipse will rebuild it automatically (if you have the “Build Automatically” option selected in Project menu, which is enabled by default)
Run Client Project
In Package Explorer View select the XX project
Right click the project and select Run As… > 1 Android Application
Some Eclipse useful key bindings.

 Quick Press
CTRL + O: Displays a list of current class members… start typing a method name to quickly go to its declaration.
CTRL + T: Displays current type hierarchy
CTRL + E: Quick switch editor
CTRL + SHIFT + T: Opens a class type (searches all workspace, not only current project).
CTRL + 1: Quick fix…suggests alternatives to fix error in current line
CTRL + SHIFT + G: Search for references to current method/class
CTRL + SHIFT + O: Fix imports
CTRL + SHIFT + F: Formats code
CTRL + Space: Content assist (try writing “sysout”+CTRL+SPACE and see what happens :) )
CTRL + L: Go to line
CTRL + D: Erases current line
CTRL + ALT + (DOWN_ARROW or UP_ARROW): Copies current line up or down
CTRL + H: Global search
CTRL + SHIFT + L: More useful key bindings!

0 comments:

Post a Comment