3 ms·
As a slight aside, we've been using retrolambda[1] in our Android game for a little while now (>10M downloads), and it's been fantastic. There's an "Auto conver
by stickydink 11y ago
As a slight aside, we've been using retrolambda[1] in our Android game for a little while now (>10M downloads), and it's been fantastic. There's an "Auto convert to lambdas" in Eclipse that shrunk our code down nicely, and then we've transitioned into designing our code _for_ Java 8, and I'd argue it's made things much easier to work with.
The only niggle is that when you set your IDE to Java 8 (be it Eclipse or IntelliJ) it exposes Java 8's new methods - and allows those on our desktop machine builds. We've been caught out a few times as it compiles just fine for Android, then explodes at runtime on device - but never anything that didn't get caught in QA. If you just want the lambdas and method referencing, it's wonderful.
Curiously, we do get crash reports coming in from select Android devices that still don't have some of the standard library from Java 7 implemented. That catches us out in production more often but, fortunately, it looks like >99% have no issue with 7.
[1] https://github.com/orfjackal/retrolambda https://github.com/orfjackal/retrolambda
- reagency 11y agoHave you tried hacking your library classpath to make your eclipse project see the java7 classes?
- stickydink 11y agoJust to make things awkward for ourselves; we have tools that _do_ use real Java 8, as do some of our unit tests :) It's not so bad, I was just trying to come up with negatives -- we've made the mistake of pushing something to a device with the bad APIs perhaps 4-5 times in a year.
- vixsomnis 11y agoI'm glad to hear this works well, as I was doubtful of adding another layer of complexity (I'm not using an IDE). I just started learning the Android API and working on an app idea, and I was really surprised when a lambda expression I used failed to compile. I was even more surprised when it wasn't just a configuration problem on my end. I'm going to try this out.
- stickydink 11y agoThe tricky part was the integration really. We're using Eclipse (our project is getting kinda old), and we can deploy to a PC or device. We use Gradle to do our real builds; CI and to devices at our desks. And we just use Eclipse set up to run with Java 8 for everything else. Once it's setup, it's pretty seamless, we haven't had to think about it for a long time.
- vorg 11y ago> Once it's setup Always a catch.
- vixsomnis 11y agoIt was painless for me. Literally, just added plugins { id "me.tatarka.retrolambda" version "3.1.0" } to the top of my gradle.build "mobile" module file. JCenter worked, although the README said to use Maven. Probably more complex using an IDE (rather than pure gradle).
- inyorgroove 11y agoI am confused by this tool. They talk about taking all the invokeDynamic instruction into old style anonymous classes. I had assumed that the invokeDynamic instruction was introduced in Java 7, its not clear if the transformation is really necessary on Android. Am I making a terrible assumption here?
- cmircea 11y agoIt converts lambdas to anonymous inner classes, just like you would write manually in Java 7.