kotlin和databinding使用配置

在app build.gradle中添加如下代码

kapt {

generateStubs = true

}

dependencies {

//...

kapt "com.android.databinding:compiler:2.3.0"

}

完整配置

kotlin和databinding的完整配置如下

project的build.gradle

buildscript {

ext.kotlin_version = '1.1.0'

ext.android_plugin_version = '2.3.0'

dependencies {

classpath 'com.android.tools.build:gradle:2.2.3'

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

//classpath "com.android.tools.build:gradle:$android_plugin_version"

}

}

app的build.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

android {

//...

dataBinding {

enabled true

}

sourceSets {

main.java.srcDirs += 'src/main/kotlin'

}

}

kapt {

generateStubs = true

}

dependencies {

//...

compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

kapt "com.android.databinding:compiler:$android_plugin_version"

}

你可能感兴趣的:(kotlin和databinding使用配置)