Search code examples
javaandroidretrolambda

What is the use of Retrolambda?


What is the use of Retrolambda?
Where do we use the Retrolambda framework?


Solution

  • In earlier versions of Android, Java 8 was not supported. Retrolambda provides a way to use "lambda expressions" on Java versions below 8.

    Common examples of lambdas in Android are for click listeners

    button.onClick(v -> Log.i("hello", "lambdas"));
    

    However, as of Android Studio 2.4 Preview 4 and later, it

    supports all Java 7 language features and a subset of Java 8 language features

    "Lambdas" are available on all SDK versions

    Android studio provides tooling to migrate from Retrolambda as it is no longer necessary.

    Android Java 8 Support

    Also, worth mentioning

    Retrolambda lacks support for third party libraries that use Java 8 language features.