Tuesday, 26 May 2015

Android Studio and Gradle in brief

The features of the Android Studio consist of the following:
  1. Intellij or the intelligent code editor -  provides powerful code editing, code completion, refactoring etc. so that developers can save a lot of time. This feature was available with the ADT bundle as well which was used for android development earlier.
  2.  UI - The new Studio is shaped for better developer interactions. Easily accessible tools and settings and all other development related buttons are their within reach and there is no need to fish around much. Also the Layout Editors are better designed and layout previews are more real looking.
  3.  Rich AVD - The AVD manager has a rich set of devices in all shapes and sizes. This is one great boon.
  4.  Built in google cloud support.
  5.  Build tools - This is one of the most confusing point for developers who switched from eclipse. I would be going to this in detail hence.
    • Android Studio makes use of the Gradle build tools which is an automated build toolkit, basically a plugin. It consists of a set of files to configure and manage the build process. The scripts are based on the Groovy programming language.  
    • Compared to Eclipse IDE, where the developers were unaware about the backend apk building process, Android studio’s Gradle allows a seamless way for developers to manage their builds. With this plugin you will be able to build different versions of the same project like paid, unpaid or device specific apks etc. Developers can also trigger the build from command line as well.
    • The gradle allows including dependencies from within your local repos as well as remote repos. The gradle build normally takes place by assuming a default project convention or structure. It also gives you the freedom to alter your project structure; only, you have to make sure to configure the build files accordingly.

There are two levels of build files: module build file and project build file.  The project level build file is the topmost and it will contain basic information. An example project gradle file is as follows:
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
         // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
 allprojects {
    repositories {
        jcenter()
    }
}

This file simply states that the build is based on the Android plugin and all the remote libraries will be obtained through the jcenter repository.
The Module build file contains the module wise build configurations. It also allows                 you override the main manifest file setting and configure custom packaging/compiling              option etc.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.demo.sample"
        minSdkVersion 19
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
debug {
            debuggable true
        }

    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services:+'
}




I hope by now you would have got an overall idea of the Android studio’s main feature. In later posts we will be discussing on setting up the Studio and building and running project on it as well, it will give you a more better understanding.

No comments:

Post a Comment