9

Let's say I create a java library independent of the Android framework. Classes/methods in this java library have been written with Java 8 streams and lambdas. I then compile my java library into a jar and add it as a dependency in my Android project.

Can my android app use that jar even though Android itself only supports Java 7?

Thanks for any info.

Kurt Mueller
  • 3,173
  • 2
  • 29
  • 50
  • No, I don't think forward-compatibility works like that. Java's jre7 does not know about the jre8 standard libraries. – Mr. Polywhirl Jan 06 '15 at 01:25
  • 2
    I just found this stack overflow post, which explains why differences in Java 7 vs 8 bytecode: http://stackoverflow.com/questions/16143684/can-java-8-code-be-compiled-to-run-on-java-7-jvm – Kurt Mueller Jan 06 '15 at 01:28
  • 1
    Android doesn't have streams in its library, even if you did make lambdas work somehow. – Louis Wasserman Jan 06 '15 at 01:36

1 Answers1

2

Do you explicitly need Java 8 compiled JARs? Otherwise you can use a retro-compiler.

I plan to use retrolambda to integrate Java 8 code into my Android project.

Jan Groth
  • 14,039
  • 5
  • 40
  • 55