After adding the following lines to build.gradle :

android { ... compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } 

I get the error:

Error: Jack is required to support java 8 language features.
Either enable Jack or remove sourceCompatibility JavaVersion.VERSION_1_8.

At the same time I did not include Jack, I don’t have to build.gradle (and never did)

 jackOptions { enabled true } 

What could be the reason that I get this error?

    2 answers 2

    As the documentation says:

    To use the new features of the Java 8 language, you must also use the new Jack toolkit. With its help, Android compiles a Java language source into a readable Android bytecode Dalvik Executable (dex). Jack has its own .jack library format, most of the functionality of the toolkit is provided within one tool: recompilation, compression, obfuscation, and the use of multiple DEX files.

    If you translate all this "nonsense" into Russian, it sounds like this:

    If you want to use the features of Java 8 (lambda expressions, repeated annotations and default methods in interfaces), then please use jack - otherwise it will not take off.

    You can use the compileOptions block in the gradle script in order to explicitly indicate what level (ver) of the language to use the compiler, you specified JAVA8.

      compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } 

    Jack compiler, not connected by default, but to work it was in it that support 8-ki, with reduced functionality, which is why you had a corresponding error.

    Error: Jack is required to support java 8 language features.

    In the new SDK with the new gradle with 3.0.0-alpha1 and higher there is no such need, because between the javac and dexc compilers, where the jack was located, now after the .class there is a desugar layer as the thirdLibrary and it is already embedded.

    enter image description here Therefore, it so happened that you updated Gradle SDK. You did not specify the jack block, otherwise you would have to remove it and everything started. And in the box you had such magic.

    But like Jack, you can turn off Desugar in gradle.properties:

     android.enableDesugar=false