Android Question Lambda expression and Simple Library Compiler

Discussion in 'Android Questions' started by agraham, Jul 25, 2019.

  1. agraham

    agraham Expert Licensed 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?
    error: lambda expressions are not supported in -source 7
                post(() -> {
      (use -source 
    8 or higher to enable lambda expressions)
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. agraham

    agraham Expert Licensed User

    Thanks Erel - I'll think that I'll give up on this idea. :(
  4. moster67

    moster67 Expert Licensed 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.
  5. wes58

    wes58 Active Member Licensed User

    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
  6. Erel

    Erel Administrator Staff Member Licensed User

    Once you compile the library with Eclipse or Android Studio it is very simple to make it compatible with the current build chain. Just run desugar and it will convert the byte code.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice