无法在Kotlin中启用数据绑定

huangapple 未分类评论48阅读模式
英文:

Can't enable Data Binding in Kotlin

问题

我最近开始使用 Kotlin 进行开发。我刚刚学习了关于数据绑定的内容,但是我无法启用数据绑定。

我在互联网上搜索了一些信息,大多数地方都很清楚地说明我必须使用 Kotlin 的 "kapt" 插件并更新依赖项来显式启用数据绑定。

所以,我按照推荐的方式进行了应用。

apply plugin: 'kotlin-kapt'

android {
   ...
   dataBinding {
       enabled true
   }
}

dependencies {
   ...
   kapt 'com.android.databinding:compiler:3.6.3'
}

错误信息如下:

> Task :app:kaptDebugKotlin FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
   > java.lang.reflect.InvocationTargetException (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

我使用的 Android Gradle 插件版本为 3.6.3,Gradle 版本为 5.6.4。
英文:

I've recently started developing using Kotlin. I've just learnt about data binding, but I'm not able to enable data binding.

I searched on the internet and it was pretty clear at majority of places that I had to enable it explicitly using "kapt" plugin of kotlin and update the dependencies.

So, I applied as it was recommended.

apply plugin: 'kotlin-kapt'

android {
   ...
   dataBinding {
       enabled true
   }
}


dependencies {
   ...
   kapt 'com.android.databinding:compiler:3.6.3'
}

The error is :

> Task :app:kaptDebugKotlin FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:kaptDebugKotlin'.
    > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
    > java.lang.reflect.InvocationTargetException (no error message)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

I have Android gradle plugin version 3.6.3 and gradle version 5.6.4.

huangapple
  • 本文由 发表于 2020年5月19日 21:27:42
  • 转载请务必保留本文链接:https://java.coder-hub.com/61892240.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定