Android For The Beginner


Required Software For Android:
  • Java 6 (Java 5 supported only by older Android versions , Java 7 can technically be used, but new Java 7 features not supported)
  • Eclipse with ADT Plugin (Latest version (3.7 – Indigo) recommended. Previous version (3.6 – Helios) still supported, Older versions (3.5 and earlier) not supported)
  • Updated SDK components
  • AVD (Android Virtual Device)
  • Windows, Linux, Solaris, MacOS where Java is preinstalled & updated automatically.

Install the Android Development Tools (ADT) plugin for Eclipse:

Next, we will use Eclipse to install the Android Development Tools (ADT) using Eclipse’s built-in plug-in system. From within Eclipse:
  1. Choose “Help” > “Install New Software….”
  2. Click the “Add…” button and create a new entry:
  3. Check all the boxes to install all the tools
  4. Just keep clicking “I agree”, “Next”, “Yes”, etc. until it asks you to restart
  5. Go ahead and restart Eclipse when prompted to.
  6. Run Android SDK Manager Should be prompted; if not,
    Windows  Android SDK Manager
Optional: disable sending stats to Google-
   Window => Preferences => Android => Usage Stats      18
 
AVD (Android Virtual Device):
An AVD (Android Virtual Device) is an Android Emulator configuration that lets you model an actual device by defining hardware and software options.
Emulator Shortcuts:
The following shortcuts are useful for working with the emulator.
Alt+Enter Maximizes the emulator. Nice for demos.
Ctrl+F11 changes the orientation of the emulator.
F8 Turns network on / off.
Create and run Android Virtual Devices (AVDs):
  1. To define an Android Virtual Device (ADV) open the AVD Manager dialog via Windows AVD Manager
  2.  Press new button.
  3.  New interface will be opened. Provide following Information-
- Name (Anything you want to named)
- Target (Android 2.2 API Label 8)
-Size (512 MiB)
-Skin Built-in: HVGA
    4.  Click on Create AVD button
    5. You can check the AVD by clicking “Start” button.
Ø  If your AVD not start then take or copy the path (G:\Android\US\android-sdk-windows\tools) where you’re android SDK’s tools folder remain.
Ø  Then right click on my computer => Properties=>Advanced =>Environment Variables
Ø  User Variable :
New=>Variable name:”PATH”, Variable value:” G:\Android\US\android-sdk-windows\tools”(paste the copied path)=>ok
Ø  System variables:
select “Path” variable => Edit=>paste the copied path with “
;” Sami colon.=>ok
Ø  Restart the PC.

How to develop a “HellowWorld” project by Android in Eclipse:
  v  File=>New =>Android Project=>Write Project Name ,Package Name (minimum two folder),Tick on Android 2.2=>finish.

Structure or Configuration of a Android Project in Eclipse:
After creating a new project in eclipse, we will see the following top-level folders in Android project package explorer-
  1. src
  2. gen
  3. assets
  4. res
    a)drawable(hdpi,ldpi,mdpi),
    b)layout,
    c)values
  5. AndroidManifest.xml
  6. default.properties
  7. proguard.cfg
1)      /src:

This folder will contain the Java source files that will be created.  ‘activity’ files will be created here for the project. The files inside this folder will be organized according to the package structure. This is similar to the /src folder which is present in any normal Java project.

2)    /gen:
This is also a source folder, but will be contain Java source files that will be automatically generated by the android platform. The framework will generate R class file                  

3)    /res: This directory contains all the external resources (images, data files etc) that are used by the android application. These external resources (content) will be referenced in the android application.This contains the following sub-folders
/res/drawable/res/layout/res/Values

/res/drawable
This folder contains all images, pictures etc. If you want to include an image or an icon in your android application, then you will be placing it in this folder.

/res/layout
This folder contains the UI layouts that will be used in the project. These UI layouts are stored as XML files
.
/res/Values
- This folder again contains XML files, which contain key values pairs that will be referenced in the application.
- These XML files declare Arrays, colors, dimensions, strings etc.
- The main idea of having these values in a separate XML file is that the values can be used based on the locale without actually changing the source code. For example the messages in the application can be in different languages based on the use locale.

/assets
This folder also contains external resources used in the application like the /res folder. But the main difference is that the resources are stored in raw format and can be read only programmatically. (It’s just like j2ee .class file folder)

AndroidManifest.xml
ð  This is an XML file which contains meta information about the android application and is important file for every android application project.
ð   It contains information about various activities, views, services etc.
ð   It also contains the list of user permissions that are needed to run the android application.

project.properties
This file contains project settings, such as the build target and links to the project being tested. This file is integral to the project, so maintain it in a source revision control system. To edit project properties in Eclipse, right-click the project folder and select Properties.

ProGuard.cfg
The ProGuard tool shrinks, optimizes, and obfuscates your code by removing unused code and renaming classes, fields, and methods with semantically obscure names. The result is a smaller sized .apk file that is more difficult to reverse engineer. Because ProGuard makes your application harder to reverse engineer.
It is important that we use it when your application utilizes features that are sensitive to security like when we are Licensing our Applications.
ProGuard is integrated into the Android build system, so we do not have to invoke it manually. 

No comments:

Post a Comment