Zor*_*gan 4 android gradle kotlin
我已经准确复制了kotlin gradle 文档所说的内容来实现 kotlin gradle 插件,但是它返回以下错误:
Could not find method kotlin() for arguments [gradle-plugin, 1.3.20] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
我的等级
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
}
Run Code Online (Sandbox Code Playgroud)
任何想法?
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"
}
}
Run Code Online (Sandbox Code Playgroud)
这里: https: //kotlinlang.org/docs/reference/using-gradle.html#targeting-android
您还可以通过创建一个空的 Android 和 Kotlin 项目来找到一个不错的示例。
| 归档时间: |
|
| 查看次数: |
4464 次 |
| 最近记录: |