bounty将在6天后到期。回答此问题可获得+50声望奖励。HelloCW正在寻找来自信誉良好的来源的答案。
代码A来自https://developer.android.com/training/data-storage/room#groovy
代码B来自https://developer.android.com/training/data-storage/room#kts
如果我需要使用Kotlin扩展和协程支持Groovy设置的Room,我需要在代码A中添加implementation("androidx.room:room-ktx:$room_version")
吗?
代码A
dependencies {
def room_version = "2.5.1"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
// To use Kotlin annotation processing tool (kapt)
kapt "androidx.room:room-compiler:$room_version"
// To use Kotlin Symbol Processing (KSP)
ksp "androidx.room:room-compiler:$room_version"
...
}
代码B
dependencies {
val room_version = "2.5.1"
implementation("androidx.room:room-runtime:$room_version")
annotationProcessor("androidx.room:room-compiler:$room_version")
// To use Kotlin annotation processing tool (kapt)
kapt("androidx.room:room-compiler:$room_version")
// To use Kotlin Symbol Processing (KSP)
ksp("androidx.room:room-compiler:$room_version")
// optional - Kotlin Extensions and Coroutines support for Room
implementation("androidx.room:room-ktx:$room_version")
...
}
2条答案
按热度按时间gtlvzcf81#
是的,如果你想在Room中使用Kotlin扩展和协程支持,你需要在Gradle文件中添加以下实现依赖:
lb3vh1jj2#
是的,您应该将implementation(“androidx.room:room-ktx:$room_version”)添加到Room中,将其与Kotlin协程一起使用