I talked about basics of lambda expressions and method references, which are among the new features introduced in Java 8, in part I and part II of this series. Remember, not all the new features of Java 8 are available in Android. In this final part, I am going to explain about what changes you all have to make in build.gradle file , for using the two features in Android. The two features are supported in every version of Android, given that you make following changes on your build.gradle file

apply plugin: ''
//Android 1.0.0+ Gradle plugin
//as it contains DSL for jackOptions
android {
  compileSdkVersion 24
  //build tool version  21.1.1 and above
  // as it contains jack compiler
  buildToolsVersion "24.0.1"
  defaultConfig {
    applicationId "com.wordpress.laaptu.lambdawithandroid"
    //other stuff
    //jack compiler is needed if we are going to work with Java 8 features
    jackOptions.enabled true
 //we need to specify that we are interested
 //in using Java8 features in compileOptions
  compileOptions {
    targetCompatibility 1.8
    sourceCompatibility 1.8

This is all required , for you to work with lambda expression and method reference features in Android. You can check up this github link for the samples that use the two features of Java 8.  This is all for lambda expression in Android and do check upon following references for more



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s