“这个项目附带的一些Kotlin库有不支持的格式。请更新库或插件”

我已经安装了kotlin插件到我的android studio项目中。代码符合了一个问题。 当我从java类调用它时,它也会执行。 它给我的警告“附加到这个项目的一些Kotlin库有不支持的格式。请更新库或插件”。 println()函数在IDE中也不被识别。

test.kt

fun foo(){ println("ad") } public class iTar{ public fun printAll( vararg a: String ){ for(item in a)println(item) } } 

的build.gradle

 buildscript { ext.kotlin_version = '0.8.679' repositories { mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { compileSdkVersion 20 buildToolsVersion "20.0.0" sourceSets { main.java.srcDirs += 'src/main/kotlin' } packagingOptions { exclude 'META-INF/LGPL2.1' exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' } defaultConfig { applicationId "xxxxx" minSdkVersion 14 targetSdkVersion 20 versionCode 1 versionName "1.0" } buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'org.codehaus.jackson:jackson-mapper-lgpl:1.9.13' compile 'com.j256.ormlite:ormlite-android:4.48' compile 'org.mapsforge:svg-android:0.4.3' compile 'com.android.support:support-v4:20.+' compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } repositories { mavenCentral() } 

你的问题来自你的Gradle构建中使用Kotlin 0.8.679,这对于你在IDE中使用的Kotlin插件来说太新了。 两种可能的解决方

  • 更新你的插件到一个更新的每晚构建,或者
  • 在你的Gradle构建中使用0.8.11