Android - Environment Setup Chapter 2

Android - Environment Setup

.

You will be glad to know that you can start your Android application development on either of the following operating systems −
  • Microsoft Windows XP or later version.
  • Mac OS X 10.5.8 or later version with Intel chip.
  • Linux including GNU C Library 2.7 or later.
Second point is that all the required tools to develop Android applications are freely available and can be downloaded from the Web. Following is the list of software's you will need before you start your Android application programming.
  • Java JDK5 or later version
  • Android Studio
Here last two components are optional and if you are working on Windows machine then these components make your life easy while doing Java based application development. So let us have a look how to proceed to set required environment.

Set-up Java Development Kit (JDK)

You can download the latest version of Java JDK from Oracle's Java site − Java SE Downloads. You will find instructions for installing JDK in downloaded files, follow the given instructions to install and configure the setup. Finally set PATH and JAVA_HOME environment variables to refer to the directory that contains java and javac, typically java_install_dir/bin and java_install_dir respectively.
If you are running Windows and installed the JDK in C:\jdk1.8.0_102, you would have to put the following line in your C:\autoexec.bat file.
set PATH=C:\jdk1.8.0_102\bin;%PATH%
set JAVA_HOME=C:\jdk1.8.0_102
Alternatively, you could also right-click on My Computer, select Properties, then Advanced, then Environment Variables. Then, you would update the PATH value and press the OK button.
On Linux, if the SDK is installed in /usr/local/jdk1.8.0_102 and you use the C shell, you would put the following code into your .cshrc file.
setenv PATH /usr/local/jdk1.8.0_102/bin:$PATH
setenv JAVA_HOME /usr/local/jdk1.8.0_102
Alternatively, if you use Android studio, then it will know automatically where you have installed your Java.

Android IDEs

There are so many sophisticated Technologies are available to develop android applications, the familiar technologies, which are predominantly using tools as follows
  • Android Studio
  • Eclipse IDE(Deprecated)

Android - Eclipse


Set-up Android SDK

You can download the latest version of Android SDK from Android official website − Android SDK Downloads. If you are installing SDK on Windows machine, then you will find a installer_rXX-windows.exe, so just download and run this exe which will launch Android SDK Tool Set up wizard to guide you throughout of the installation, so just follow the instructions carefully. Finally you will have Android SDK Tools installed on your machine.
If you are installing SDK either on Mac OS or Linux, check the instructions provided along with the downloaded android-sdk_rXX-macosx.zip file for Mac OS and android-sdk_rXX-linux.tgz file for Linux. This tutorial will consider that you are going to set up your environment on Windows machine having Windows 7 operating system.
So let's launch Android SDK Manager using the option All Programs > Android SDK Tools > SDK Manager, this will give you following window −
Once you launched SDK manager, its time to install other required packages. By default it will list down total 7 packages to be installed, but I will suggest to de-select Documentation for Android SDK and Samples for SDK packages to reduce installation time. Next click Install 7 Packages button to proceed, which will display following dialogue box −
If you agree to install all the packages, select Accept All radio button and proceed by clicking Install button. Now let SDK manager do its work and you go, pick up a cup of coffee and wait until all the packages are installed. It may take some time depending on your internet connection. Once all the packages are installed, you can close SDK manager using top-right cross button.

Set-up Eclipse IDE

All the examples in this tutorial have been written using Eclipse IDE. So I would suggest you should have latest version of Eclipse installed on your machine.
To install Eclipse IDE, download the latest Eclipse binaries from https://www.eclipse.org/downloads/. Once you downloaded the installation, unpack the binary distribution into a convenient location. For example in C:\eclipse on windows, or /usr/local/eclipse on Linux and finally set PATH variable appropriately.
Eclipse can be started by executing the following commands on windows machine, or you can simply double click on eclipse.exe
%C:\eclipse\eclipse.exe
Eclipse can be started by executing the following commands on Linux machine −
$/usr/local/eclipse/eclipse
After a successful start up, if everything is fine then it should display following result −

Set-up Android Development Tools (ADT) Plug-in

This step will help you in setting Android Development Tool plug-in for Eclipse. Let's start with launching Eclipse and then, choose Help > Software Updates > Install New Software. This will display the following dialogue box.
Now use Add button to add ADT Plug-in as name and https://dl-ssl.google.com/android/eclipse/ as the location. Then click OK to add this location, as soon as you will click OK button to add this location, Eclipse starts searching for the plug-in available the given location and finally lists down the found plug-ins.
Now select all the listed plug-ins using Select All button and click Nextbutton which will guide you ahead to install Android Development Tools and other required plug-ins.

Create Android Virtual Device

To test your Android applications you will need a virtual Android device. So before we start writing our code, let us create an Android virtual device. Launch Android AVD Manager using Eclipse menu options Window > AVD Manager> which will launch Android AVD Manager. Use New button to create a new Android Virtual Device and enter the following information, before clicking Create AVD button.
If your AVD is created successfully it means your environment is ready for Android application development. If you like, you can close this window using top-right cross button. Better you re-start your machine and once you are done with this last step, you are ready to proceed for your first Android example but before that we will see few more important concepts related to Android Application Development.

Android - Studio


Step 1 - System Requirements

You will be delighted, to know that you can start your Android application development on either of the following operating systems −
  • Microsoft® Windows® 10/8/7/Vista/2003 (32 or 64-bit)
  • Mac® OS X® 10.8.5 or higher, up to 10.9 (Mavericks)
  • GNOME or KDE desktop
Second point is that all the required tools to develop Android applications are open source and can be downloaded from the Web. Following is the list of software's you will need before you start your Android application programming.
  • Java JDK5 or later version
  • Java Runtime Environment (JRE) 6
  • Android Studio

Step 2 - Setup Android Studio

Overview

Android Studio is the official IDE for android application development.It works based on IntelliJ IDEA, You can download the latest version of android studio from Android Studio 2.2 Download, If you are new to installing Android Studio on windows,you will find a file, which is named as android-studio-bundle-143.3101438-windows.exe.So just download and run on windows machine according to android studio wizard guideline.
If you are installing Android Studio on Mac or Linux, You can download the latest version from Android Studio Mac Download,or Android Studio Linux Download, check the instructions provided along with the downloaded file for Mac OS and Linux. This tutorial will consider that you are going to setup your environment on Windows machine having Windows 8.1 operating system.

Installation

So let's launch Android Studio.exe,Make sure before launch Android Studio, Our Machine should required installed Java JDK. To install Java JDK,take a references of Android environment setup
Once you launched Android Studio, its time to mention JDK7 path or later version in android studio installer.
Below the image initiating JDK to android SDK
Need to check the components, which are required to create applications, below the image has selected Android StudioAndroid SDKAndroid Virtual Machine and performance(Intel chip).
Need to specify the location of local machine path for Android studio and Android SDK, below the image has taken default location of windows 8.1 x64 bit architecture.
Need to specify the ram space for Android emulator by default it would take 512MB of local machine RAM.
At final stage, it would extract SDK packages into our local machine, it would take a while time to finish the task and would take 2626MB of Hard disk space
After done all above steps perfectly, you must get finish button and it gonna be open android studio project with Welcome to android studio message as shown below

You can start your application development by calling start a new android studio project. in a new installation frame should ask Application name, package information and location of the project.
After entered application name, it going to be called select the form factors your application runs on, here need to specify Minimum SDK, in our tutorial, I have declared as API23: Android 6.0(Mashmallow)
The next level of installation should contain selecting the activity to mobile, it specifies the default layout for Applications
At the final stage it going to be open development tool to write the application code.

Step 3 - Create Android Virtual Device

To test your Android applications, you will need a virtual Android device. So before we start writing our code, let us create an Android virtual device. Launch Android AVD Manager Clicking AVD_Manager icon as shown below
After Click on a virtual device icon, it going to be shown by default virtual devices which are present on your SDK, or else need to create a virtual device by clicking Create new Virtual device button
If your AVD is created successfully it means your environment is ready for Android application development. If you like, you can close this window using top-right cross button. Better you re-start your machine and once you are done with this last step, you are ready to proceed for your first Android example but before that we will see few more important concepts related to Android Application Development.

Hello Word Example

Before Writing a Hello word code, you must know about XML tags.To write hello word code, you should redirect to App>res>layout>Activity_main.xml
To show hello word, we need to call text view with layout ( about text view and layout, you must take references at Relative Layout and Text View).
<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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

<TextView android:text="@string/hello_world"
android:layout_width="550dp"
android:layout_height="wrap_content" />
</RelativeLayout>
Need to run the program by clicking Run>Run App or else need to call shift+f10key. Finally, result should be placed at Virtual devices as shown below
Previous                                                                                          Next

Post a Comment

Previous Post Next Post