我完全复制了科特林·格拉德尔医生说来实现kotlin插件,但是它返回了以下错误:
Could not find method kotlin() for arguments [gradle-plugin, 1.3.20] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
my gradle
buildscript {
ext.kotlin_version = '1.3.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath(kotlin("gradle-plugin", version = "1.3.20"))
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
// ext {
// navigationVersion = '28.0.0'
// }
plugins {
kotlin("<...>")
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}有什么想法吗?
发布于 2019-02-02 01:48:10
build.gradle可以用Groovy或Kotlin编写。您在Groovy (不是Kotlin)中键入build.gradle,但是您已经复制了Kotlin代码。您应该在文档中选择Groovy选项卡:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.3.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20"
}
}这里:https://kotlinlang.org/docs/reference/using-gradle.html#targeting-android
通过创建一个空的Android和Kotlin项目,您也可以找到一个不错的例子。
https://stackoverflow.com/questions/54489134
复制相似问题