Android Studio 3.0.0에서 데이터 바인딩 및 Kotlin을 사용하는 방법
Android Studio 3.0.0을 사용하기 시작했지만 프로젝트를 빌드하려고 할 때마다이 오류가 발생합니다.
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"
그리고 그것은 잘 작동하고 있었다 ... 내가 뭘 잘못하고 있니 ??
감사!
데이터 바인딩을 추가하려면 모듈 수준에서 앱 .gradle에 3 개의 gradle 항목이 필요한 것 같습니다.
apply plugin: 'kotlin-kapt'
android { ... dataBinding { enabled = true } }
dependencies { ...... kapt "com.android.databinding:compiler:$compiler_version" }
단일 위치에서 관리 할 수 있도록 프로젝트 수준 빌드 gradle에서 컴파일러 버전을 변수로 만들었습니다.
기본값은 다음과 같습니다. ext.kotlin_version = '1.1.3-2'
대괄호 구문으로 추가했습니다.
ext{
kotlin_version = '1.1.3-2'
compiler_version = '3.0.0-beta6'
}
UPD : 이 문제는 Android Gradle 플러그인 3.0.0-alpha3에서 수정되었습니다. 프로젝트 루트 build.gradle
에서 buildscript
dependencies
사용하도록 변경하세요.
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
이것은 실제로 Kotlin Gradle 플러그인 1.1.2-4와 Android Gradle 플러그인 3.0.0-alpha1의 상호 운용에서 발생하는 버그로, 작업의 입력 및 출력이 설정되는 방식 (따라서 작업이 의존 관계).
KT- 17936 문제를 만들어 주신 @VyacheslavGerasimov 에게 감사드립니다 .
임시 해결 방법으로 Kotlin Gradle 플러그인 1.1.2-2로 되돌리고 증분 컴파일을 비활성화 할 수 있습니다.
프로젝트의 root build.gradle
에서 Kotlin Gradle 플러그인의 버전을 변경합니다.
buildscript {
...
dependencies {
...
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-2'
}
}
local.properties
다음 줄을 사용하여 프로젝트 루트에 추가 합니다.
kotlin.incremental=false
Kotlin Gradle 플러그인 1.1.2-2 이하가 최신 AGP 버전과 충돌 하는 것은 알려진 문제 이며 증분 컴파일을 비활성화하면 충돌이 해결되는 것 같습니다.
For those still looking for a proper solution, Google has already fixed this issue in Android Studio 3.0 Canary 3 build.
Friday, June 2, 2017
We have just released Android Studio 3.0 Canary 3 to the Canary and Dev Channels. The Android Gradle Plugin 3.0.0-alpha3 was also released through maven.google.com. This release has fixes to Gradle, Kotlin, and many other fixes. We continue to fix bugs in all areas of Studio 3.0 as we stabilize our features, so please continue to pass on feedback.
Working gradle configuration:
build.gradle (project)
buildscript {
ext.kotlin_version = '1.1.2-4'
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
build.gradle (module)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
dataBinding.enabled = true
}
dependencies {
kapt "com.android.databinding:compiler:3.0.0-alpha3"
}
I have recenly write Blog for Data Binding android with Kotlin here
Use Classpath
classpath 'com.android.tools.build:gradle:3.0.0-beta2'
Dependency
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
...
dataBinding {
enabled = true
}
}
dependencies {
......
kapt 'com.android.databinding:compiler:2.3.1'
}
for more detail check out this post
'IT story' 카테고리의 다른 글
구조체를 휘발성으로 만들면 모든 멤버가 휘발성이됩니까? (0) | 2020.08.30 |
---|---|
Git 인터랙티브 리베이스 선택 커밋 없음 (0) | 2020.08.30 |
단일 파일에 대한 컴파일 플래그 무시 (0) | 2020.08.30 |
Ruby / Rails-값을 변경하지 않고 시간의 시간대 변경 (0) | 2020.08.30 |
React / Redux / Typescript 알림 메시지에서 컴포넌트를 마운트 해제, 렌더링 해제 또는 제거하는 방법 (0) | 2020.08.30 |