Search code examples
androidkotlingradlegradle-kotlin-dsl

Gradle Kotlin DSL and freeCompilerArgs


On one project I have used sucesfully argument -XXLanguage:-ProperCheckAnnotationsTargetInTypeUsePositions in kotlinOptions to disable "typeUsage" check on annotations. This project has regular build.gradle in Groovy. However when I have used exactly same approach on same version of Kotlin (1.6.0) in fresh project with Kotlin DSL gradle files (build.gradle.kts) it seems like this argument is ignored totally.

Summarizing:

  • project with good-old Groovy gradle -> argument works and disable error on "wrong usage of annotations"
  • project with new Kotlin DSL gradle -> argument seems to be ignored and still produces error

Maybe someone has same issue? This is connected with Compatibility of android annotations with Kotlin 1.6.0


Solution

  • kotlinOptions {
        jvmTarget = "1.8"
        freeCompilerArgs = listOf("-XXLanguage:-ProperCheckAnnotationsTargetInTypeUsePositions")
    }