method references are not supported at this language level解决方法

Directly above the picture
This is what I was prompted when writing a program
, the solution is to add the following code under build.gradle under the APP.

android {
    
    
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
    
    
        applicationId "com.wuyr.catchpiggy"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 2
        versionName "1.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
    
    
        release {
    
    
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    //todo 添加的代码
    compileOptions {
    
    
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}

Okay, after adding it, click Sync Now in the upper right corner , and the bug will be solved.

Guess you like

Origin blog.csdn.net/qq_42221857/article/details/103670000