[英]How fix build.gradle?
Connected my module and in build.gradle
write next:连接我的模块并在
build.gradle
写下一个:
plugins {
id("org.jlleitschuh.gradle.ktlint")
kotlin("jvm")
}
dependencies {
compileOnly(kotlin("stdlib"))
compileOnly(kotlin("reflect"))
compileOnly(kotlin("script-runtime"))
compileOnly("com.pinterest.ktlint:ktlint-core:0.34.2")
}
and get next error:并得到下一个错误:
startup failed: build file '/home/vadimm/AndroidStudioProjects/homework/target-list/custom_ktlint_rules/build.gradle': 3: only id(String) method calls allowed in plugins {} script block
启动失败:构建文件“/home/vadimm/AndroidStudioProjects/homework/target-list/custom_ktlint_rules/build.gradle”:3:插件{}脚本块中只允许调用 id(String) 方法
See https://docs.gradle.org/5.1.1/userguide/plugins.html#sec:plugins_block for information on the plugins {} block
有关 plugins {} 块的信息,请参阅https://docs.gradle.org/5.1.1/userguide/plugins.html#sec:plugins_block
@ line 3, column 5. kotlin("jvm") ^
@ 第 3 行,第 5 列。kotlin("jvm") ^
1 error
1 错误
Also tried write smth like this: apply plugin: 'kotlin'
or也试过这样写:
apply plugin: 'kotlin'
或
plugins {
id 'kotlin'
}
but it is not successful但它没有成功
I have faced similar issue.
我遇到过类似的问题。 Following solution works for me.
以下解决方案对我有用。 Good Luck!!
祝你好运!!
plugins {
kotlin("kapt")
id("dagger.hilt.android.plugin")
}
to到
plugins {
id("kotlin-kapt")
id("dagger.hilt.android.plugin")
}
如果有人在尝试使用 Kotlin DSL 时遇到此错误并希望保留它:确保您的文件是build.gradle.kts
,而不是build.gradle
Resolved with next solution:解决了下一个解决方案:
apply plugin: 'kotlin'
dependencies {
compileOnly("org.jetbrains.kotlin:kotlin-stdlib")
compileOnly("org.jetbrains.kotlin:kotlin-reflect")
compileOnly("org.jetbrains.kotlin:kotlin-script-runtime")
compileOnly("com.pinterest.ktlint:ktlint-core:0.34.2")
}
kotlin("jvm") is Gradle kotlin-dsl syntax. kotlin("jvm") 是 Gradle kotlin-dsl 语法。 For common Gradle syntax use apply plugin: 'kotlin' kotlin("..") is also from Gradle kotlin-dsl
对于常见的 Gradle 语法,请使用 apply plugin: 'kotlin' kotlin("..") 也来自 Gradle kotlin-dsl
Haven't tested it but this might work for you:还没有测试过,但这可能对你有用:
plugins {
id("org.jlleitschuh.gradle.ktlint")
id("kotlin-jvm")
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.