java - "Some Kotlin libraries attached to this project have unsupported format.Please update the libraries or the plugin"

标签 java android-studio kotlin

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

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

关于java - "Some Kotlin libraries attached to this project have unsupported format.Please update the libraries or the plugin",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25632134/

相关文章:

java - Spring Boot 测试@Transactional 不保存

java - Thrift 是否有 IPC 传输实现?或低延迟 SOA 解决方案

java - Couchbase并发超时异常: Java SDK

Android Studio 'Obsolete Gradle Dependency' 检查问题

java - Android studio 中的 Android 注解 - 无法访问 Activity_?

android - Dispatchers.IO协程线程

java - 如何使用水平或垂直缩放在java中读取大文件并写入文件

Android Studio 启动器图标为黑色

collections - find 和 firstOrNull 有什么区别?

generics - Kotlin 中可以有一个通用的主构造函数吗?