如何在 Android Studio 3.0.0 中使用数据绑定和 Kotlin [英] How to use Data Binding and Kotlin in Android Studio 3.0.0

查看:40
本文介绍了如何在 Android Studio 3.0.0 中使用数据绑定和 Kotlin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用 Android Studio 3.0.0,但每次我尝试构建我的项目时都会出现此错误:

I just started to use Android Studio 3.0.0, but every time I try to build my project I get this error:

Error:Circular dependency between the following tasks:
:app:compileDebugKotlin
+--- :app:dataBindingExportBuildInfoDebug
|    \--- :app:compileDebugKotlin (*)
\--- :app:kaptDebugKotlin
     \--- :app:dataBindingExportBuildInfoDebug (*)
(*) - details omitted (listed previously)

我正在使用

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

在我使用之前

androidProcessor "com.android.databinding:compiler:2.2.0"

而且它工作得很好......我做错了什么??

And it was working just fine... What I am doing wrong??

谢谢!

推荐答案

看来你需要在 app .gradle 模块级别的 3 个 gradle 条目来添加数据绑定

It seems that you need 3 gradle entries in the app .gradle at module level to add data binding

  1. 应用插件:'kotlin-kapt'
  2. android {...数据绑定{启用 = 真}}
  3. 依赖项{......kapt "com.android.databinding:compiler:$compiler_version"}

请注意,我在项目级构建 gradle 中将编译器版本设置为变量,以便可以从一个地方对其进行管理

Notice that I made compiler version a variable in the project level build gradle so it can be managed from a single place

默认为:ext.kotlin_version = '1.1.3-2'

我添加了括号语法:

ext{
    kotlin_version = '1.1.3-2'
    compiler_version = '3.0.0-beta6'
}

这篇关于如何在 Android Studio 3.0.0 中使用数据绑定和 Kotlin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆