android gradle error. Default interface methods are only supported starting with Android N (–min-api 24):

How to fix when this error occurs when you built an android app on android studio.

Default interface methods are only supported starting with Android N (--min-api 24): 

Cause and solution

Because you wrote code that uses java8 functions, or you used java8 functions in a library that you imported with gradle, but you have not specified java8 in compileOptions of gradle.
So, if you write ↓ in defaultConfig of build.gradle, it is OK.

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}