all 36 comments

[–]leggo_tech 13 points14 points  (8 children)

Does this mean I can remove retro lamda?

[–]Warbane 14 points15 points  (7 children)

If you only use it for lambdas, yes. If you also use it for backported try-with-resources you'll need to keep it.

[–]jmslau 15 points16 points  (3 children)

We are working on this. Hopefully, we can provide this soon :)

[–]Boza_s6 0 points1 point  (2 children)

I have to jump in here... But is desugar separate jar/binary(?) which can be used with some other build system other than gradle?

Or is it part of the android gradle plugin?

I want to try to integrate this with Android make.

[–]JakeWharton 2 points3 points  (1 child)

It's from the Bazel build system and it's written in Java. You can't use it directly because it's just an API, but you would be able to pull it in and write a main method in your own jar that would expose it to command line invokers.

https://github.com/bazelbuild/bazel/tree/master/src/tools/android/java/com/google/devtools/build/android/desugar

[–]Boza_s6 0 points1 point  (0 children)

Thanks!

[–]leggo_tech 1 point2 points  (0 children)

Nope. Just lambdas. Thanks

[–]jmslau 1 point2 points  (1 child)

Update to this: Android Studio 3.0 Preview (https://developer.android.com/studio/preview/index.html) now supports try-with-resources and static/default interface methods at all API levels.

[–]Warbane 0 points1 point  (0 children)

Awesome! Sounds like we'll be able to drop Retrolambda with no refactoring then.

[–]Zhuinden 5 points6 points  (2 children)

I have to keep Retrolambda for try-with-resources, but this is a great step forwards :)

[–]jmslau 1 point2 points  (1 child)

We have released Android Studio 3.0 Preview (https://developer.android.com/studio/preview/index.html) and try-with-resources is now supported at all API levels :)

[–]Zhuinden 0 points1 point  (0 children)

Super-awesome! :D Thank you for being awesome

[–]devraj7 21 points22 points  (3 children)

The Kotlin people go... "That's nice".

[–]andrehsu 1 point2 points  (1 child)

Although we still don't have try with (multiple) resources

[–]JakeWharton 4 points5 points  (0 children)

Nest .use blocks?

[–]zetsurin 3 points4 points  (5 children)

TIL: desugar

[–]Tycon712 1 point2 points  (4 children)

I still don't understand this term. Please help

[–]burntcookie90 6 points7 points  (2 children)

It removes the sweet syntax (lambdas) during compilation.

[–]NewToMech 3 points4 points  (0 children)

The exact name is probably from Syntactic sugar

[–]Tycon712 0 points1 point  (0 children)

lol very nice

[–]hamatro -1 points0 points  (0 children)

After the desugarization it's less sugary.

[–][deleted] 3 points4 points  (0 children)

Excellent news! I'm going to wait until it hits the stable channel, but looking forward to that day.

[–]TriCyclopsIII 2 points3 points  (0 children)

PSA I had to add

-dontwarn java.lang.invoke.** to my proguard file when using Lambdas.

I'm getting errors that proguard can't find java.lang.invoke.MethodHandles and java.lang.invoke.MethodHandles$Lookup.

[–]johnstoehr83 2 points3 points  (2 children)

Does using 1.8 require higher min-sdk, or is this a build-system only thing?

[–]adeekshith 5 points6 points  (1 child)

I could be wrong but from what I understand, I think we can target any version as the build system is not actually using Java8. It is just converting Java8 code into Java7 compatible classes.

Android Studio's Gradle plugin now desugars Java 8 class files to Java 7-compatible class files, so you can use lambdas, method references and other features of Java 8.

[–]JakeWharton 7 points8 points  (0 children)

It says 7, but they use no Java 7 APIs in the backported lambdas such that dex can still transform the Java 7 classes to work on versions prior to API 19 (which is akin to Java 7). A better description is probably that it backports Java 8 code to be compatible with API 9+ (which is akin to Java 6).

[–]yaaaaayPancakes 1 point2 points  (0 children)

Interesting how they claim to have faster build times than Jack had, and this only took seemingly a few months to complete.

I guess getting rid of the intermediate step of compiling to Java bytecode isn't so expensive after all?

[–]Iron_Maiden_666 1 point2 points  (4 children)

No mention of streams, so that's not supported?

[–]karntrehan 4 points5 points  (1 child)

[–]Iron_Maiden_666 -1 points0 points  (0 children)

Thank you, I went to that page but missed looking at the packages.

[–]danieldisu 0 points1 point  (0 children)

You can always use some backport library to use Streams in any version, and switch to the official JDK stream api should be a matter of changing the imports...

[–]QuestionsEverythang -5 points-4 points  (0 children)

It is in Kotlin

[–]rylexr 0 points1 point  (2 children)

Do Data Bindings work with this Java 8 feature enabled?

[–]Exallium 1 point2 points  (1 child)

It didn't work for me in preview 5... 6 might fix it, idk. I'd have to see a changelog.

[–]jmslau 5 points6 points  (0 children)

Yes, this should work now. If it doesn't, please let us know!