Android is an operating system designed for mobile phones and tablets. It is developed for a consortium of hardware, software and telecommunications companies leaded by Google. Nowadays it is the most-used smartphone platform worldwide with more apps developed, whereas iOS from Apple is the platform with more app downloads.
The programming language used to develop Android applications is Java and the most used IDE is Eclipse. The Android SDK provides all the tools and API libraries to build, test and debug the Android apps. In this post I will try to show you how to build your first Android app.
1. Installing the Android SDK
The first step consists on download and install the Android SDK. Once installed, you can download the packages from the Android SDK Manager.
2. Adding Platforms and Packages
The Android SDK Manager allows to download the platforms and tools, which are needed to develop an Android app. Available packages on the SDK Manager are: tools for debugging and testing apps, documentation for the Android platform APIs, the SDK platform and system images for each version of Android, a collection of samples, the Google APIs and the support libraries.
3. Installing the ADT Plugin for Eclipse
The Eclipse IDE for Java Developers contains what you need to build Java applications but you can also use any other IDE for Java. However, if you use Eclipse you have to install the ADT Plugin. It extends the capabilities of Eclipse to build Android apps with UI interfaces and using Android Framework packages.
4. Creating an Android Project
Open Eclipse and click on New > Project > Android Project. Firstly you have to set the Application Name (name that appears to users), Project Name (name of your project visible in Eclipse), Package Name (package namespace for your app), the SDK version against which you will compile your app and the minimum SDK required. The following screens provides tools to create a launcher icon for the app and templates from which begin building the app.
5. The Android Project
The Android project created includes a default set of “Hello World” source files:
- src/ Directory for the app’s main source files coded in Java.
- res/ Directory which contains app resources:
- drawable/ Drawable objects such as bitmaps.
- layout/ Files that define the user interface.
- values/ XML files that contains a collection of resources (strings, color definitions…)
- Androidmanifest.xml Define all components of the app and describes the fundamental characteristics.
5. Running the app
You can install and run the app on an Android device or on the emulator.
5.1 Run on a real device
Plug in your Android device on the computer with the USB cable to run the app on the device. You might need to install the USB driver. Once installed enable USB debugging on the device on Settings > Developer Options.
5.2 Run On the emulator
To run the app on the emulator an Android Virtual Device (AVD) has to be created. Launch the Android Virtual Device Manager click New, get it a name, a platform target, a SD card size and create the AVD.
To run the app from Eclipse, click the Run button from the toolbar. The app will be automatically installed and it will start running on the AVD.