-1

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

9
  • 1
    It's to be able to use Java 8's lambda functionality into Android. You'd use it if you want to use lamdbas
    – Ken Wolf
    Apr 28, 2017 at 11:32
  • what is backport ?
    – Alis
    Apr 28, 2017 at 11:32
  • I've edited my comment
    – Ken Wolf
    Apr 28, 2017 at 11:33
  • 1
    Wherever you want to use lamdbas
    – Ken Wolf
    Apr 28, 2017 at 11:41
  • 1
    stackoverflow.com/a/30752800/833647
    – Ken Wolf
    Apr 28, 2017 at 11:43

2 Answers 2

6

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.

3
  • My point is that it isn't necessary to use it anymore. OP probably found some old tutorials that mention it Apr 28, 2017 at 12:13
  • 4
    It is necessary for everybody who wants to use lambdas and not develop with preview builds of AS. Anyway suggesting someone should use B where the question is asking what A is used for probably belongs in a comment
    – Tim
    Apr 28, 2017 at 12:18
  • Yeah, I rephrased. Thanks for the typo fixes Apr 28, 2017 at 12:23
3

Retrolambda is a library which allows to use Java 8 lambda expressions, method references and try-with-resources statements on Java 7, 6 or 5.

The Gradle Retrolambda Plug-in allows to integrate Retrolambda into a Gradle based build. This allows for example to use these constructs in an Android application, as standard Android development currently does not yet support Java 8.

TextView textView = (TextView) findViewById(R.id.text_view);

textView.setOnLongClickListener(v -> System.out.println("Long Click"));

you can use this link : https://mayojava.github.io/android/java/using-java8-lambda-expressions-in-android

1
  • 1
    That link is outdated as Java 8 features are in the Android Studio canary channel. Without Jack compiler Apr 28, 2017 at 12:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.