Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin and Android Databinding

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?

like image 749
Stepango Avatar asked Jun 19 '15 17:06

Stepango


People also ask

How to bind data to an Android app using Kotlin?

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 {

What is databinding in 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() .

What is data binding in Android jetpack?

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.

What is MVVM android Data Binding library?

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() .


1 Answers

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).

like image 193
yigit Avatar answered Sep 21 '22 02:09

yigit