IntelliJ
の既存のKotlinプロジェクトにgradle
を追加した後、いくつかの標準ライブラリ要素への参照に問題が発生しました。例えば、Kotlin String
タイプが認識されるが、mutableMapOf
は私にKotlin(JVM)標準ライブラリ要素の未解決の参照
Error:(11, 60) Kotlin: Unresolved reference: mutableMapOf
別を与えている。
Error:(9, 78) Kotlin: Unresolved reference: Array
コンパイル時に。彼らはここでKotlin
を設定するには、オプションなしで、IntelliJ
に表示されます
別のエラーがKotlin not configured
である(唯一のコンパイルには単離されていない)だけでなく、IDEに赤でマークされている私のGradleのビルドファイルです:
apply plugin: 'kotlin'
group = "com.serguei.myproject"
version = "1.0"
buildscript {
ext.kotlin_version = '1.2.10'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile 'com.google.code.gson:gson:2.8.2'
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
IntelliJでこのプロジェクトを削除して、それをgradleで再インポートする必要がありますか? – ice1000
私は試してみましたが、残念ながら私はまだ同じ問題を抱えています。提案していただきありがとうございます@ ice1000 –
私は同じ問題を経験しました。プロジェクトを削除し、すべてのビルドフォルダをクリーンアップし、再インポートして更新しましたか? 'gradle --refresh-dependencies ...'を実行してビルドする前に強制的にリフレッシュするようにしてください。 –