Invoke-customs are only supported starting with android 0 --min-api 26

When I Run the Android app in Android studio returns an error with this message

"Invoke-customs are only supported starting with android 0 --min-api 26"

After googling I have found a solution for the issue "Invoke-customs are only supported starting with android 0 --min-api 26"

by adding a Java8 compilation in build.gradle file

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

 

Refer here