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

- 37,901
- 21
- 84
- 115

- 193
- 1
- 2
- 10
-
1It'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 '17 at 11:32
-
what is backport ? – Alis Apr 28 '17 at 11:32
-
I've edited my comment – Ken Wolf Apr 28 '17 at 11:33
-
I can use in android app? – Alis Apr 28 '17 at 11:34
-
Yes you can! Try it – Ken Wolf Apr 28 '17 at 11:35
-
where we use retrolambda in our app? – Alis Apr 28 '17 at 11:37
-
1Wherever you want to use lamdbas – Ken Wolf Apr 28 '17 at 11:41
-
give me any type of example? – Alis Apr 28 '17 at 11:42
-
1http://stackoverflow.com/a/30752800/833647 – Ken Wolf Apr 28 '17 at 11:43
2 Answers
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.
Also, worth mentioning
Retrolambda lacks support for third party libraries that use Java 8 language features.

- 41,901
- 18
- 127
- 145

- 179,855
- 19
- 132
- 245
-
My point is that it isn't necessary to use it anymore. OP probably found some old tutorials that mention it – OneCricketeer Apr 28 '17 at 12:13
-
4It 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 '17 at 12:18
-
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

- 4,198
- 2
- 22
- 29
-
1That link is outdated as Java 8 features are in the Android Studio canary channel. Without Jack compiler – OneCricketeer Apr 28 '17 at 12:03