安卓数据绑定(bind) : How to avoid "cannot find the KaptTask" warning

标签 android android-databinding

我有一个包含多个库模块的大型 Android 项目。它们都使用 Kotlin,并且许多都启用了数据绑定(bind)。该项目和所有模块构建和运行都很好,没有错误。

但是,对于我认为是误报的每个模块,我在 Gradle 同步日志中收到警告:

> Configure project :feature-a
Kotlin plugin is applied to the project :feature-a but we cannot find the KaptTask. Make sure you apply the kotlin-kapt plugin because it is necessary to use kotlin with data binding.

> Configure project :feature-b
Kotlin plugin is applied to the project :feature-b but we cannot find the KaptTask. Make sure you apply the kotlin-kapt plugin because it is necessary to use kotlin with data binding.

> Configure project :feature-c
Kotlin plugin is applied to the project :feature-c but we cannot find the KaptTask. Make sure you apply the kotlin-kapt plugin because it is necessary to use kotlin with data binding.

[... etc. for dozens of modules ...]

我已检查以确保正确应用了“kotlin-kapt”插件。我正在为所有模块使用 Kotlin Gradle DSL,并像这样应用插件:

plugins {
    id("com.android.library")
    id("kotlin-android")
    id("kotlin-android-extensions")
    id("kotlin-kapt")
    id("androidx.navigation.safeargs.kotlin")
}

是什么导致了这个警告,它真的是一个问题吗?我该如何让它消失?

最佳答案

如果您在 buildSrc/build.gradle[.kts] 中声明了 Android Gradle 插件依赖项,也会出现此问题:https://issuetracker.google.com/issues/123491449

解决此问题的方法是在 buildSrc/build.gradle[.kts] 中声明 ALL 插件依赖项,而不是在根项目的 build 中声明.gradle[.kts] 文件

关于安卓数据绑定(bind) : How to avoid "cannot find the KaptTask" warning,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61808379/

相关文章:

java - 从FTP下载图片:Caused by: java. lang.OutOfMemoryError

android - FirebaseApp 已删除

android - 您上传的 APK 或 Android App Bundle 具有带有 Intent 过滤器的 Activity 、 Activity 别名、服务或广播接收器,但没有“an”

android-studio - Android studio 3.1 beta 数据绑定(bind)和 kapt

android - 使用 Android 数据绑定(bind)时禁用 Kotlin 合成绑定(bind)

android - 如何修复 "Support-v13:19.1.0 depends on libraries but is not a library itself"?

android - 从 AppWidgetProvider 访问小部件的元素

Android DataBinding "??"符号和来自资源的参数化字符串。如何避免 'null' 文本?

android - @BindingAdapter 不适用于 Android Kotlin 库

android - 错误 :Execution failed for task ':app:transformClassesWithPreJackRuntimeLibrariesForDebug'