Installation
Guide of Eclipse & integration of
Android SDK & ADT
plug-in :
First What we Require to Develop an Android Apps :
(1)install JDk /JRE we require to run Eclipse:
(2)Download eclipse from:
(3)extract it into C: drive:
C:/eclipse
(4) then open eclipse folder & open eclipse.exe file & open
it to install eclipse.
Note: during installation it will
ask for workspace :
Then choose path as follows:
C:\Users\vissicomp\workspace
After successful installation now
you have to install ADT plugins:
To install ADT plug-in:
(5)Go to Help menu & then click on install new
Software
& type following link:
& then select developer tools
& proceed for installation.
(6)now you have to download Android
SDk from:
(7)then we have to go and open eclipse
go to window menu
& under window menu -> Click on preferences
->click on Android-> then browse Sdk
Location where you have kep your Android Sdk folder which is downloaded from:
Then proceed click on next .. then
it will start installing all Android Sdk packages..
Install all 18 packages from it.
(7)now your are ready to create an small apps which will display hello
world:
(8)open eclipse:
Go to file menu->then go to new
option ->then go to Project->then
select -> Android ->Android
Application project->click on next->
Then type your Application
name,Project name ,Package name & select Android version for development ..
Then click on next -> &
create activity ..& finally finish.
See below images to make it clear:
Now see & understand Android Project Directory Structure:
src
User specified java source code files will be available here.
gen
The gen directory in an Android project contains auto generated files. You can see R.java inside this folder which is a generated class which contains references to certain resources of the project. R.java is automatically created by the Eclipse IDE and any manual changes are not necessary
res
Android supports resources like images and certain XML configuration files, these can be keep separate from the source code. All these resources should be placed inside the res folder. This res folder will be having sub-folders to keep the resources based on its type.
/res/values
Used to define strings, colors, dimensions, styles and static arrays of strings or integers. By convention each type is stored in a separate file, e.g. strings are defined in the res/values/strings.xml file.
/res/values-v11 is the values of the API version 11, and /res/values-v14 is the values of the API version 14
/res/animator
This folder contains animations in XML for the property animation API which allows to animate arbitrary properties of objects over time
/res/layout
This folder contains the layouts to be used in the application.A layout resource defines the architecture for the UI in an Activity or a component of a UI. These are resource directories in an application that provides different layout designs for different screen sizes
/res/layout - layout for normal screen size or default
/res/layout-small - layout for small screen size
/res/layout-large - layout for large screen size
/res/layout-xlarge -layout for extra-large screen size
/res/layout-xlarge-land - layout for extra-large in landscape orientation
/res/layout-sw600dp - layout for tablets or layout for 7” tablets (600dp wide and bigger)
/res/layout-sw720dp - layout for 10” tablets (720dp wide and bigger)
/res/layout-w600dp - layout for Multi-pane (any screen with 600dp available width or more)
/res/menu
This folder contains menu resources to be used in the application (Options Menu, Context Menu, or submenu)
/res/raw
This folder contains raw resources that can be looked up by their resource IDs. These resources can be referenced from other resources all of the same way we do with other resources.
/res/drawable
Drawable folders are resource directories in an application that provides different l bitmap drawables for medium, high, and extra high density screens.
/res/drawable-mdpi - bitmap for medium density
/res/drawable-hdpi - bitmap for high density
/res/drawable-xhdpi - bitmap for extra high density
/res/drawable-nodpi - bitmap with no pre-scaling
libs
External library files will be placed in this folder. If you want to any external library in your project place the library jar inside this folder and it will be added to the classpath automatically.
assets
This folder contains raw hierarchy of files and directories, with no other capabilities. It is just an unstructured hierarchy of files, allowing you to put anything you want there and later retrieve as raw
byte streams.
bin
Bin folder is the area used by the compiler to prepare the files to be finally packaged to the application’s APK file. This includes
Compiling your Java code into class files
Putting your resources (including images) into a structure to be zipped into the APK
This is the output directory of the build. This is where you can find the final .apk file and other compiled resources.
AndroidManifest.xml
All the android applications will have an AndroidManifest.xml file in the root directory. This file will contain essential information about the application to the Android system, information the system must have before it can run any of the application's code. This control file describes the nature of the application and each of its components
ic_launcher-web.png
This is an icon to be used in Google play. Applications on Google Play require a high fidelity version of the application icon. It is not used in your actual app or the launcher, so it is not packaged in the APK.. The specifications for the high-resolution icon are:
32-bit PNG with an alpha channel
512 x 512 pixels
Maximum size of 1024KB
proguard-project.txt
Everything in the proguard-project.txt file will be in commented out state, because in general most people don't have any project specific needs, just to run ProGuard tool with standard settings.
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.
project.properties
project.properties is the main project’s properties file containing information such as the build platform target and the library dependencies has been renamed from default.properties in older SDK versions. This file is integral to the project.
Thats all about Android eclipse project directory structure...
in our example see in below images
(1)Src :
it containts
Mainactivity.java file
(2)gen : it contains
R.java file
(3)res :
Contains values folder->values contains ->strings.xml
(4)bin : it contains res folder ->under res folder it
contains Androidmanifest.xml file &
Apk file (for example your project name is om then it will contains
om.apk file)
To make it clear see below images:
Now see all following codes for display a simple :”hello
world “ apps.
(1)Code for MainActivity.java:
package om.hello;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
@Override
protected void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean
onCreateOptionsMenu(Menu menu) {
// Inflate the
menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean
onOptionsItemSelected(MenuItem item) {
// Handle
action bar item clicks here. The action bar will
//
automatically handle clicks on the Home/Up button, so long
// as you
specify a parent activity in AndroidManifest.xml.
int id =
item.getItemId();
if (id ==
R.id.action_settings) {
return
true;
}
return
super.onOptionsItemSelected(item);
}
}
(2)activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="om.hello.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
(3)Strings.xml:
<?xml
version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Om</string>
<string name="hello_world">Hello world!</string>
<string name="name">welcome to Vissicomp Courses</string><string
name="action_settings">Settings</string>
</resources>
Now create AVD(android Virtual Device ):
To do it go to
Window->then click on Android virtual Device Manger & create
AVD..
& finally click on run & run your project
Output will be like that: