Error: lambda expressions are not supported in -source 1.7 (use -source 8 or higher to enable lambda expressions)

Viewed 2572

I am getting this error message while building the Cordova Android app.

Error:(159, 66) error: lambda expressions are not supported in -source 1.7 (use -source 8 or higher to enable lambda expressions)

enter image description here

The following compileOptions has been set on my build.gradle (module android) and build.gradle (module CordovaLib) as you can see here:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

enter image description here

How to resolve this problem?

1 Answers

The error stems from your app module. You have to set up Java 8 for each separate module. Go to File > Project Structure and update it from the Properties tab for that module or make sure you have added the compileOptions snippet to the correct build.gradle file of your app module.

If there are further modules, make sure they are set up for Java 8, before using Java 8 functionality.

For full reference, see the official Android Java 8 Support Page.

Related