首页 > 解决方案 > 任何处理器都无法识别 Kapt 选项

问题描述

我不明白为什么 kotlin 注释处理器无法解析这些参数。

我的 build.gradle.kts 的相关部分

plugins {
    id("kotlin-kapt")
}

android {
    defaultConfig {
        kapt {
            arguments {
                arg("room.incremental", "true")
                arg("room.schemaLocation", "$projectDir/schemas")
            }
        }
    }
}

dependencies {
    implementation("androidx.room:room-runtime:${Versions.room_version}") // room_version = "2.2.4"
    kapt("androidx.room:room-compiler:${Versions.room_version}")
    implementation("androidx.room:room-ktx:${Versions.room_version}")
}

我得到的确切警告是

> Task :app:kaptDebugKotlin
warning: The following options were not recognized by any processor: '[room.schemaLocation, kapt.kotlin.generated, room.incremental]'
The following options were not recognized by any processor: '[room.schemaLocation, kapt.kotlin.generated, room.incremental]'

标签: androidgradlekotlinandroid-roomgradle-kotlin-dsl

解决方案


如果您的代码不使用您的任何Annotation processor's注释,则 kapt 任务将被跳过并且不会调用注释处理器,因此您传递的选项将被忽略,因为没有调用的注释处理器(如果有)对它们感兴趣。


推荐阅读