'Compilation failed: lambda expressions are not supported in -source 6 (use -source 8 or higher to enable lambda expressions) in Android Debugger
i'm trying to using the Optional to null-checking and get JsonObject using Gson
final User user = RequestUtils.customDeserializerGson().fromJson(json, User.class);
Optional<JsonElement> jsonAvatar = Optional.ofNullable(json)
.filter(je -> je.isJsonObject())
.map(je -> je.getAsJsonObject())
.map(jso -> jso.get("avatar"))
.filter(jeAvatar -> jeAvatar.isJsonObject());
if ((user.getAvatar() == null) && jsonAvatar.isPresent()) {
UserAvatar avatar = RequestUtils
.customDeserializerGson()
.fromJson(jsonAvatar.get(), UserAvatar.class);
user.setUserAvatar(avatar);
}
When i'm debugging the Optional part and try to add an expression containing a lambda expression:
Optional.ofNullable(json).filter(je -> je.isJsonObject())
, it can't show the result and said "Compilation failed: lambda expressions are not supported in -source 6 (use -source 8 or higher to enable lambda expressions)"
I have enabled to use the Java 8+ API desugaring support base on https://developer.android.com/studio/write/java8-support#library-desugaring to use Optional feature, but its weird that its not work in Android Debugger, can anyone help me ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

