首页 > 解决方案 > 工作室 3.2.1 中的 kapt 编译器问题,带有数据绑定和空间

问题描述

在所有生成的绑定类中构建失败并出现错误“找不到符号 DataBindingComponent”。如果我从我的模块 gradle 中删除房间编译器依赖项,那么它在运行时无法找到房间数据库,说“Db_Impl 不存在”。

def room_version = "1.1.1"
implementation "android.arch.persistence.room:runtime:$room_version"
//kapt "android.arch.persistence.room:compiler:$room_version"
//kapt 'com.android.databinding:compiler:3.2.1'  

标签: androidandroid-roomandroid-databindingkapt

解决方案


依赖项 { def room_version = "2.1.0-alpha06"

implementation "androidx.room:room-runtime:1.1.1"
annotationProcessor "androidx.room:room-compiler:1.1.1" // For Kotlin use kapt instead of annotationProcessor

// optional - Kotlin Extensions and Coroutines support for Room
implementation "androidx.room:room-ktx:1.1.1"

// optional - RxJava support for Room
implementation "androidx.room:room-rxjava2:1.1.1"

// optional - Guava support for Room, including Optional and ListenableFuture
implementation "androidx.room:room-guava:1.1.1"

// Test helpers
testImplementation "androidx.room:room-testing:1.1.1"

}


推荐阅读