Monday, 2 January 2017

Installing 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
Android Studio
Once you launched Android Studio, its time to mention JDK7 path or later version in android studio installer.
Android Studio Installation
Below the image initiating JDK to android SDK
Android Studio Installation
Need to check the components, which are required to create applications, below the image has selected Android Studio, Android SDK, Android Virtual Machine and performance(Intel chip).
Android Studio Installation
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.
Android Studio Installation
Need to specify the ram space for Android emulator by default it would take 512MB of local machine RAM.
Android Studio Installation
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.
Android Studio Installation
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
Android Studio Installation
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.
Android Studio Installation
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)
Android Studio Installation
The next level of installation should contain selecting the activity to mobile, it specifies the default layout for Applications
Android Studio Installation
At the final stage it going to be open development tool to write the application code.
Android Studio Installation

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
Android Studio Installation
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
Android Virtual Device
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 Project Structure

  Any Android project contain things such as application source code and resource files. Some are generated for you by default, while others should be created if required. Lets have a look at android eclipse project directory structure below :

Android Project Files-




Android Studio Project View - When you select Project view, you can see a lot more files and directories. The most important of which are the following:



1. src- 

User specified java source code files will be available here.

2. 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

3. 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.

4. /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

5. /res/animator

This folder contains animations in XML for the property animation API which allows to animate arbitrary properties of objects over time

6. /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)

7. /res/menu

menu resources to be used in the application (Options Menu, Context Menu, or submenu)

8. /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.

9. /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

10. 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 class path automatically.

11. 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.

12. 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.

13. 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.

14. 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.


15. Gradle Files

build.gradle (module)


This defines the module-specific build configurations.
build.gradle (project)

This defines your build configuration that apply to all modules. This file is integral to the project, so you should maintain them in revision control with all other source code.


That's all about Android Studio project directory structure...