question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

3.x release vs. Java 8 support on Android

See original GitHub issue

Recently, the news came that Android Studio 4 will support a so-called “desugaring” of Java 8 APIs (i.e., some kind of auto-backport for target devices not supporting newer API levels as I understand). This would allow RxJava 3 to increase the baseline support to Java 8 on its surface API:

  • Stream support
  • Stream Collectors support
  • Optional support
  • CompletableFuture support
  • Use site non-null annotations

Some features won’t be supported:

  • java.time.Duration: allocates, we’ll stick to time+unit
  • java.util.function: these can’t throw Throwables, overloads would create bloat and/or ambiguity

The main issue with Android’s Java 8 support is timing related to the pledged release schedule of RxJava 3.x, end of December 2019. AGP 4 may not release for months, inclining us to:

  • Wait for AGP’s release, effectively parking RxJava 3 for months as release candidate. Drawback: AGP may slip a lot.
  • Release on schedule with Java 6 baseline. Drawback: AGP may release shortly after and thus
    • we’d be stuck on 3.x for years;
    • we’d have to start working on 4.x undermining 3.x in a sense, also adding more maintenance burden;
    • we release 3.1 with baseline 8, abandoning 3.0 and possibly violating some pledge;
  • Release on schedule with Java 8 baseline. Drawback: 3.x improvements won’t be available to many at release.
  • Release on schedule with Java 8 bytecode output but no 8 API use, add those in 3.1. Drawback: despite best efforts, this could cause problems with existing desugaring/tooling.

The same issue is likely to arise with the next step, Java 9 support on Android. From our perspective, support for the Flow.* interfaces would be just enough as none of the other 9 features would work (VarHandles - field reflection anomalies?, Cleaner - portable?, Modules?). Beyond 9, the next major change to RxJava would have to come due to value types (no version ETA yet). Loom/Fibers is likely simply an API expansion, not a fundamental change.

Suggestions, ideas welcome.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:16 (15 by maintainers)

github_iconTop GitHub Comments

5reactions
akarnokdcommented, Dec 17, 2019

Okay. Let’s upgrade to RxJava 8 baseline and release without delaying too much.

2reactions
akarnokdcommented, Dec 10, 2019

I have cobbled together a small library that uses Java 8 API and features.

I’ve created a basic Android Studio 3.5.2 project using it from maven local and kept modifying the compileSdkVersion, minSdkVersion and targetSdkVersion to 14, 24 and 29.

  • 14: Methods with Stream, CompletionStage, Duration and Optional won’t compile
  • 24: Methods with Duration won’t compile
  • 29: okay

Also tried AS 4 canary 5

  • 14: CompletableFuture gives IDE error (minSdk >= 24 required), the project deploys successfully but fails at runtime with missing class. CompletionStage interface gives no error but its methods do.
  • 24: okay
  • 29: okay
Read more comments on GitHub >

github_iconTop Results From Across the Web

Use Java 8 language features and APIs - Android Developers
Java 8 language feature support (Android Gradle Plugin 3.0.0+); Java 8+ API desugaring support (Android Gradle Plugin 4.0.0+). Versions.
Read more >
Android jumps on Java release train - mobile it
​​For many years, Android was stuck with Java 8. Finally, we got a big update. The gap between Java 8 and Java 9...
Read more >
Is it possible to use Java 8 for Android development?
Android does not support Java 8. It only supports up to Java 7 (if you have kitkat) and still it doesn't have invokedynamic,...
Read more >
Java 8 in Android Apps - PSPDFKit
Android Studio 3.0 introduced support for a subset of Java 8 language features and APIs for Android apps. This article gives an overview...
Read more >
Java Versions and Features - Marco Behler
As of September 2022, Java 19 is the latest released Java version. In March 2023, Java 20 will follow. The last long-term support...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found