Android Fast way to setup Retrolambda on an android project. Setup and example how to use:

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Setup Steps:

  1. Download and install jdk8.

  2. Add the following to your project’s main build.gradle

    buildscript {
        repositories {
            mavenCentral()
        }
    
        dependencies {
            classpath 'me.tatarka:gradle-retrolambda:3.2.3'
        }
    }
    
  3. Now add this to your application module’s build.gradle

    apply plugin: 'com.android.application' // or apply plugin: 'java'
    apply plugin: 'me.tatarka.retrolambda'
    
  4. Add these lines to your application module’s build.gradle to inform the IDE of the language level:

    android {
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }
    

Example:

So things like this:

button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        log("Clicked");
    }
});

Become this:

button.setOnClickListener(v -> log("Clicked"));


Got any Android Question?