Bogotobogo
contact@bogotobogo.com
New! Android Forum
- 1. Introduction
- 2. My First Android Application
- 3. Back to Hello World Again
- 4. Basic User Interface
- 5. Layouts
- 6. ListView, Spinner, GridView, and Gallery
- 7. Advanced ListView Widget
- 8. DatePicker, TimePicker, and Clocks
- 9. TabWidget, Flipper, and SlidingDrawer
- 10. Menus
- 11. Android JUnit Test
- 12. Activity Testing
- 13. Intent
- 14. On Notepad Example
- 15. Configuring Rotation
- 16. Preferences
- 17. Map View
- 18. Manifest
- 19. Animation - Frame By Frame, Layout, and View
- 20. Notification and Service
- 21. Content Provider
- 22. Threads
- 23. HTTP Internet Connection
- 24. Media
- 25. Activity Life Cycle
- Apps - Mortagage Calculator
Others
1. Introduction
- 1.1 What is Android?
- 1.2 What do we need to develop Android applications?
- 1.3 Eclipse Update Manager for Android Development Tools (ADT)
- 1.4 Configuration
- 1.5 Device for Emulation - Android Virtual Device (AVD)
Android is an operating system based on Linux with a Java programming interface, targeted at mobile hardware such as phones and tablet computers. It seems that it keeps increasing market share in smartphone and even trying to get footing into TV world (Google TV with Android OS).
It provides tools, e.g. a compiler, debugger and a device emulator as well as its own Java Virtual machine (Dalvik). Android is created by the Open Handset Alliance which is lead by Google.
Android uses a special Java virtual machine (Dalvik) which is based on the Apache Harmony Java implementation. Dalvik uses special bytecode there you cannot run standard Java program on Android but you have to use the Android compiler to create this special byte-code.
Android supports 2-D and 3-D graphics using the OpenGL libraries and supports data storage in a SQLLite database.
For development Google provides the Android Development Tools (ADT) for Eclipse to develop Android applications.
Android's Linux kernel-based OS doesn't come with a sophisticated shell environment, but because the platform is open, we can write and install shells on a device.
Android platform releases 1 through 2 are aimed primarily at smartphone devices, whereas Android release 3 will be the first operating platform specifically designed with high-end support for tablet computers.
The API level targeted by our application is important for device compatibility and the software development.
-
JDK (version 6 or 7 required).
We should have a recent version of the Java SDK (JDK) installed on our system.
To see what compatible version of the JDK is installed, do a quick check on the command line as below:$ java -version java version "1.7.0_02" Java(TM) SE Runtime Environment (build 1.7.0_02-b13) Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode) $ javac -version javac 1.7.0_01
Now, Java platform is ready to go. - Eclipse IDE for Java Developers (version 3.6-Helios or 3.7-Indigo).
- Base Android SDK
We now need to download the Android SDK starter package and use it to install our target Android platforms.
Download the Android SDK from the Android homepage. The download contains a zip file which you can extract to any place in your file system, e.g. I placed it under "C:\apps\android-sdk-windows".
The Android SDK archive only contains the tools, and we need to use the SDK Manager to install or update SDK components such as platforms, tools, etc. We must install at least one version of the Android platform using the SDK Manager in order to start developing applications. - Android Development Tools (ADT)
Intalling using Eclipse Update Manager as shown in the next section of this tutorial is much easier.
Use the update manager of Eclipse to install all available plugins for the Android Development Tools (ADT).
From Elicpse, Help->Install New Software
In the Available Software dialog, click Add. Then, type in "Android Plugin" in the Name field and URL "https://dl-ssl.google.com/android/eclipse/" in the Location field.
Then, hit OK.
Hit OK, again and select the checkbox next to Developer Tools. Then, the nested tools Android DDMS and Android Development Tools will be selected automatically.
In the Install Details dialog, the Android DDMS and Android Development Tools features are listed.
Click Next.
Click Finish, and restart Eclipse.
In Eclipse, open the Preferences dialog via Windows -> Preferences.
Select Android and type in the installation path of the Android SDK as the picture below.
After hit Apply, we get:
Hit OK after set the target.
Select Window -> Android SDK Manager from the menu.
Install packages if needed.
(Note) We can also get the SDK Manager using following command:
$ androidor
$ "sdk manager.exe"
For emulation, we need to define a device.
Select Window -> Android AVD Manager from the menu.
Press "New", then you are about to create a New AVD as the picture below.
Hit "Create AVD" button.
Then you will have
To test if your setup is correct, select your device and press "Start".
Check the "Scale display to real size" at the Launch Options window below.
At the Launch button, you will have the device, finally.
- Linux and Mac OS X
~/.android/avd/ - Windows XP
C:\Documents and Settings\<user>\.android\avd\ - Windows Vista
C:\Users\<user>\.android\avd\
Android SDK Development Tool Commands
| Android SDK Development Tool | Linux/Mac OS X | Windows |
|---|---|---|
| Android SDK and AVD Manager | android | android.bat |
| Dalvik Debug Monitor | ddms | ddms.bat |
- Open the import Dialog
Select File > Import ... to open the import dialog. - Import the "MyProject" project
In the import dialog, expand the General node and select Existing Projects into Workspace, then click Next to move to the Import Projects step. Make sure that Select root directory is selected, then click the Browse... button.
In the Browse For Folder dialog, locate the "MyProject" folder, select it and click OK. Then, click Finish to import the project. The project now shows up in the Package Explorer. - Launch the "MyProject" project
Right click the "MyProject" in the Package Explorer window, and then select Run As > Android Application from the menu.
When we have the following line of code from the imported package, depending on the compliance level, we may get error message from Eclipse:
@Override
public void onClick(DialogInterface dialog, int button)
{
In my case, I got:
Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead.
since I'm using Java 1.7. In this case, we need to set the compliance level to 1.6 because 1.5 won't work with the @Override annotation. Right click on the Project -> Properties, then select Java Compiler, the set it 1.6 as in the picture below.
At Apply, we get:
Hit "Yes", and that's it.
Here is the project-wise solution. Right click the "MyProject" in the Package Explorer window, and then select Delete from the menu. In the dialog that appears, ensure that Delete project contents on disk is not selected if we want to use the project's folders in workspace. If not, we can check it before be click OK.
Full List of Android Tutorials
- 1. Introduction
- 2. My First Android Application
- 3. Back to Hello World Again
- 4. Basic User Interface
- 5. Layouts
- 6. ListView, Spinner, GridView, and Gallery
- 7. Advanced ListView Widget
- 8. DatePicker, TimePicker, and Clocks
- 9. TabWidget, Flipper, and SlidingDrawer
- 10. Menus
- 11. Android JUnit Test
- 12. Activity Testing
- 13. Intent
- 14. On Notepad Example
- 15. Configuring Rotation
- 16. Preferences
- 17. Map View
- 18. Manifest
- 19. Animation - Frame By Frame, Layout, and View
- 20. Notification and Service
- 21. Content Provider
- 22. Threads
- 23. HTTP Internet Connection
- 24. Media
- 25. Activity Life Cycle
- Apps - Mortagage Calculator