gradle - Gradle 无法解析符号
问题描述
我有以下 build.gradle 文件:
import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask
apply plugin: 'kotlin-multiplatform'
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 19
}
lintOptions {
abortOnError false
}
}
dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
testImplementation 'com.google.truth:truth:0.42'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'org.jetbrains.kotlin:kotlin-test'
androidTestImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
androidTestImplementation 'com.google.truth:truth:0.42'
}
kotlin {
targets {
jvm("jvm")
android("android")
iosArm32("ios32")
iosArm64("ios64")
iosX64("emulator")
configure([ios32, ios64, emulator]) {
binaries.framework('HyModule')
}
}
sourceSets {
commonMain.dependencies {
api 'org.jetbrains.kotlin:kotlin-stdlib-common'
}
jvmMain.dependencies {
api 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
}
androidMain.dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
}
androidMain.dependsOn jvmMain
}
task fatFramework(type: FatFrameworkTask) {
// the fat framework must have the same base name as the initial frameworks
baseName = "HyModule"
final File frameworkDir = new File(buildDir, "xcode-frameworks")
destinationDir = frameworkDir
// specify the frameworks to be merged
from(
targets.ios32.binaries.getFramework('HyModule', 'RELEASE'),
targets.ios64.binaries.getFramework('HyModule', 'RELEASE'),
targets.emulator.binaries.getFramework('HyModule', 'RELEASE')
)
doLast {
new File(frameworkDir, 'gradlew').with {
text = "#!/bin/bash\nexport 'JAVA_HOME=${System.getProperty("java.home")}'\ncd '${rootProject.rootDir}'\n./gradlew \$@\n"
setExecutable(true)
}
}
}
}
// workaround for https://youtrack.jetbrains.com/issue/KT-27170
configurations {
compileClasspath
}
tasks.build.dependsOn fatFramework
import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask
用红色标记有错误
无法解析符号“FatFrameworkTask”
尽管一切正常,但我不喜欢在我的项目中出现错误。
解决方案
尝试
import org.jetbrains.kotlin.gradle.tasks.*
我遇到了同样的问题,不知道为什么会这样
推荐阅读
- python - 在 tkinter 窗口之间来回切换
- css - 为什么文本出现在行上
- php - 如何使用 txt 文件的文件列表作为数组变量?
- python-3.x - 期望值:第 1 行第 1 列(字符 0)
- ansible - 带双引号的 ansible playbook 变量
- c++ - 尽管有范围块,std::lock_guard 似乎提供了线程安全
- android - 使用滚动视图时,Edittext 被键盘隐藏
- joomla - 如何在文章中显示导航链接
- docker - Docker 在同一个 Docker Compose 堆栈中运行时不会向 fluentd 发送日志
- java - Java:如何打开不同类型的 url,如 mailto 和 http?