1

I am an Android app developer and recently I was working with the Java 7 version and now I wanted to start developing apps with Java 8, but I have noticed that they only work for Android 7.0 . I hope I read wrong because I do not understand why they do not support Java 8 with the enormous potential it has ... and that in September comes Java 9

PS: Could you do the same apk for Android 7.0 and higher with Java 8 and for lower versions with Java 7?

  • 3
    There are libraries that make this possible. For related questions see for example [1](https://stackoverflow.com/questions/39515035/is-it-possible-to-use-the-java-8-stream-api-on-android-api-24), [2](https://stackoverflow.com/questions/37854239/stream-method-does-not-work-in-android/), [3](https://stackoverflow.com/questions/42648768/how-to-use-java-8-stream-api-under-android-6-0), [4](https://stackoverflow.com/questions/38221673/completablefuture-in-the-android-support-library/) – Sartorius Jul 26 '17 at 20:12

2 Answers2

3

I have noticed that they only work for Android 7.0

Correct. The exception is lambda expressions, which the development tools transcode into something that can work on older devices as well.

I hope I read wrong because I do not understand why they do not support Java 8

Java 8 was released in 2014. Android 1.0 was released in 2008. Google does not have a time machine that we are aware of, and so they cannot cause Java 8 to be released six years early. For compatibility reasons, Google does not replace the class library on older devices, and older devices often do not get updates anyway.

As to why it took until 2016 for portions of Java 8 to be available in Android, all anyone can do here is offer opinions (engineering time, legal issues with Oracle, etc.).

Could you do the same apk for Android 7.0 and higher with Java 8 and for lower versions with Java 7?

No. In principle, you could have separate APKs, one using Java 8 and one not, the way that you can have separate APKs for different CPU architectures and stuff. I do not know whether any app distribution channel will support separate APKs by minSdkVersion.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

I have developed with Java 8 for a long time by using retrolamda

And there is no error with it, at least now.^^

phatnhse
  • 3,870
  • 2
  • 20
  • 29