android-How to solve 'Static interface methods are only supported starting with Android N'

1. The purpose of this post

I would demo how to solve this error when using android studio

Static interface methods are only supported starting with Android N (--min-api 24): void butterknife.Unbinder.lambda$static$0()

2. Environments

  • Android Studio 3.x
  • gradle wrapper version:
    • distributionUrl=https://services.gradle.org/distributions/gradle-5.4.1-all.zip
  • project build.gradle
    • classpath ‘com.android.tools.build:gradle:3.5.0’

3. Solution and Code

Because some features need java 8 support,just add this compile options in the app’s build.gradle

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

You can get more info about android and java8 support by this official document.

Clean,rebuild and run the app, everything works.