Android Question Lambda expression and Simple Library Compiler

agraham

Expert
Licensed User
Longtime User
Using OpenJDK 11 and SLC I get this error in some source code I would like to use (steal!). Is there any way to get SLC to permit the use of lambda expressions?
B4X:
error: lambda expressions are not supported in -source 7
            post(() -> {
                    ^
  (use -source 8 or higher to enable lambda expressions)
 

moster67

Expert
Licensed User
Longtime User
If you are using Android Studio, as I do, then as I mentioned in this thread, you can simply highlight the "->" sign and then press ALT + ENTER and you get an option to automatically convert Lamda into an Anonymous class. This saves you some time rewriting the code.
Don't know if this is available in Eclipse.
 
Upvote 0

wes58

Active Member
Licensed User
Longtime User
Android doesn't support these features. You can compile it with Eclipse however you will then need to desugar the compiled jar: https://www.b4x.com/android/forum/threads/107278/#content

It is currently not possible to change the source setting in SLC.
It is supported by Android Studio because it is using D8 dexer. I have java application with Lambdas and other java 8 codes and it compiles with Android Studio.
I thought that there will be support for D8 dexer as in your post #10 in this thread https://www.b4x.com/android/forum/threads/problem-building-library-for-smbj.104232/.
 
Upvote 0
Top