Monday 27 October 2014

Gradle Configuration for an Android Studio project with Android 5.0 or L or Lollipop

This post is only about configuring an android project in Android Studio with compile and target versions set as  android L or 5.0 or Lollipop. 

    I am writing this post with the sample gradle as I faced a lot of problems while configuring Lollipop's preview version.
    I will write the sample gradle as well as the screen shot of android sdk manager to represent most basic requirements required for a project setup with target version as Lollipop.
   
    So to be able to use any feature of the Android 5.0, here is the sample gradle with support library for Android L features :



apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.0.1"

    defaultConfig {
        applicationId "your app's packagename"
        minSdkVersion 10
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.+'
 // Not compulsory just added 
    compile 'com.google.android.gms:play-services:+'
 // Support for L features for devices with lower OS versions
    compile 'com.android.support:cardview-v7:21.0.+'
    compile 'com.android.support:recyclerview-v7:21.0.+'
}

Also see the following attached screenshots to get the required SDK, various support dependencies, platforms etc to be downloaded :

Android Tools :


Android SDK 5.0(L or Lollipop)

 Minimum Android SDK (as per above gradle 2.3.3 or API level 10)

Support Libraries for L features for older devices

Please provide your comment in case of any issues.

1 comment: