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

查看:99
本文介绍了如何在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??

谢谢!

推荐答案

似乎您需要在模块级别的应用程序.gradle中添加3个gradle条目以添加数据绑定

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

  1. apply plugin: 'kotlin-kapt'
  2. android { ... dataBinding { enabled = true } }
  3. dependencies { ...... kapt "com.android.databinding:compiler:$compiler_version" }
  1. apply plugin: 'kotlin-kapt'
  2. android { ... dataBinding { enabled = true } }
  3. dependencies { ...... 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天全站免登陆