I'm trying to migrate my protect level build.gradle file from Gradle Groovy to Gradle Kotlin DSL. I've watched several tutorials but none of them clearly explain what to change the code to in the project level build.gradle
file. I only got as far as renaming the file to build.gradle.kts
.
Error
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: public infix fun PluginDependencySpec.version(version: String?): PluginDependencySpec defined in org.gradle.kotlin.dsl public infix fun PluginDependencySpec.version(version: Provider): PluginDependencySpec defined in org.gradle.kotlin.dsl
buildscript {
ext {
compose_version = "1.1.1"
}
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application" version "7.3.1" apply false)
id("com.android.library" version "7.3.1" apply false)
id("org.jetbrains.kotlin.android" version "1.6.10" apply false)
}
CodePudding user response:
Change to:
id("com.android.application") version "7.3.1" apply false
Explanation:
version
is defined as infix fun PluginDependencySpec.version(version: String)
, so it can be called as id("...").version("...")
or as id("...") version "..."
but it cannot called on String
in your invalid code:
id( "com.android.application" /*String*/ version /*??? no String.version*/ "7.3.1" apply false )
but valid:
id( "com.android.application") /*PluginDependencySpec*/ version /*OK PluginDependencySpec.version*/ "7.3.1" apply false