Updated 21.06.2015
I wanna try kotlin and android databinding in a same project. But when I add to kotlin-gradle-plugin dependency I cannot build even an empty project anymore with error:
cannot generate view binders java.lang.NoClassDefFoundError: kotlin/jvm/internal/ExtensionFunctionImpl
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0-beta3'
classpath "com.android.databinding:dataBinder:1.0-rc0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:0.12.613"
}
}
Any workaroud to make it work together?
This will be a two-step process in the app’s build.gradle file: add the Kotlin kapt plugin and add the dataBinding flag. kapt is the Kotlin-specific annotation processing plugin, which allows us to use (among other things) data binding in the app. apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android {
Android Databinding tutorial for beginners in Kotlin. Android data binding library allows us to generate binding classes for xml layout files. We can use those binding clasess to use view components efficiently without invoking findViewById() .
Data Binding Library Part of Android Jetpack. The Data Binding Library is a support library that allows you to bind UI components in your layouts to data sources in your app using a declarative format rather than programmatically.
MVVM Android Databinding tutorial for beginners in Kotlin. Android Databinding tutorial for beginners in Kotlin. Android data binding library allows us to generate binding classes for xml layout files. We can use those binding clasess to use view components efficiently without invoking findViewById() .
Unfortunately,this is caused by a kotlin version inconsistency between databinding and kotlin plugin. We'll remove kotlin dependency from the plugin on rc1 but until then you would need to use kotlin 0.11.91. Also, since kotlin's annotation processor support is limited at this moment and data binding is using annotation processor; they probably won't work well (though I have not tried).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With