如何Android Studio里使用lambda表达式

2024-11-03 10:16:48
推荐回答(1个)
回答1:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 24
buildToolsVersion "23.0.3"

defaultConfig {
applicationId "com.wj.buildapk"
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
buildscript {
repositories {
mavenCentral()
}

dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
}
}
repositories {
mavenCentral()
}

//添加插件
apply plugin: 'me.tatarka.retrolambda'
dependencies {
compile 'com.annimon:stream:1.1.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.code.gson:gson:2.2.4'
compile 'org.xutils:xutils:3.3.36'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
请自动忽略与lambda无关的配置