提问人:WISHY 提问时间:6/8/2023 更新时间:6/8/2023 访问量:189
Kotlin DSL 迁移项目 gradle 构建
Kotlin DSL migration project gradle build
问:
我正在迁移到 kotlin DSL
这是我的项目级构建gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我将文件扩展名更新为 -build.gradle.kts
并将文件内容用于
plugins {
id ("com.android.application" version "7.2.2" apply false)
id ("com.android.library" version "7.2.2" apply false)
id ("org.jetbrains.kotlin.android" version "${Versions.kotlin}" apply false)
}
tasks.register("clean",Delete::class){
delete(rootProject.buildDir)
}
我收到此错误
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<String>): PluginDependencySpec defined in org.gradle.kotlin.dsl
答:
1赞
Atick Faisal
6/8/2023
#1
更新插件块,如下所示:
plugins {
id ("com.android.application") version "7.2.2" apply false
id ("com.android.library") version "7.2.2" apply false
id ("org.jetbrains.kotlin.android") version "${Versions.kotlin}" apply false
}
另外,我认为该任务默认可用。您无需手动创建它。clean
您还可以考虑在迁移时迁移到版本目录。请遵循 NowInAndroid 应用程序源代码。
评论
version
apply
id ("com.android.application") version "7.2.2" apply false