3

Is there any issues with using Java 1.8 for an android project targetting API 14 and above? I can't find any documentation on this and would like to use Optionals.

Edit: Mainly focused on optionals (not duplicate).

0

3 Answers 3

1

for Optionals only you can also use guava - if you want other features you might want to have a look at retro-lambda

Also think twice about Optional - try to do it at compile-time as much as possible with Annotations like @Nullable @NonNull - same effect - more speed

Sign up to request clarification or add additional context in comments.

Comments

0

As far as I know you can't do this. Android works with a subset of the Java APIs and with the Java language as-of Java 1.5 (from memory). So Optional won't be available in the APIs included in Android and 1.8 language features (lambdas, etc) are not available to you when targetting Android as a platform.

You might be able to compile to Java 1.5 (language level) using the 1.8 compiler; but then you may as well just use Java 1.5. (Keeping in mind that you still need to run you project through all the Android SDK steps need to deploy it on Dalvik: you can't just build a .jar as you would a regular Java app.)

This has been my experience - though I am not a full-time Android developer.

1 Comment

I should add that I have not used Android 5.0 at all.
0

Not as far as I know.

You can use retrolambda project to use lambda expressions, but I don't know any project that back ported Optional's

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.