I want to use lambda expressions, for these two articles I took examples:

But in the end does not work.
I use java 8, android studio 1.

What else does he need, or what do I not understand?

alt text

  • 2
    undoubtedly, a screenshot with a red wavy line is a very informative description of your mistake - DreamChild

3 answers 3

Install java 8, in the project structure, specify where your jdk 1.8 lies. Then in the gradle project add the following:

buildscript { repositories { jcenter() } dependencies { ............................................... classpath 'me.tatarka:gradle-retrolambda:3.2.0' } } 

After the gradle app add the following:

 apply plugin: 'com.android.application' apply plugin: 'me.tatarka.retrolambda' android { .............................................. compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } 

    Unfortunately, so far when writing applications for Android 1.8 is not available, so the lambda and other chips new jdk will not work.

    • do they have any plans for that? - J Mas
    • That's what I do not know - Mage
    • one
      @eldqs, plans, of course. Surely work is already underway on adapting the eighth JDK to Android development, because the new JDK carries not only features, but also patches. - AseN 4:34 pm

    If you want to use lambda in Android Studio, try gradle-retrolambda . It integrates a gradle tool that converts Java 8 bytecode to Java 6/7.