Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin plugin error in android studio

I'm trying to setup kotlin plugin for android studio and following this guide. Everything compiles fine and I can use .kt files in my project. However, in every kotlin files android-studio says the following:

Kotlin library 'compiler-1.0-rc1.jar' has an unsupported format. Please update library or plugin

How can I remove this warning/error?

Here is my top-level build.gradle:

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
        classpath 'me.tatarka:gradle-retrolambda:3.2.3'
        classpath "com.android.databinding:dataBinder:1.0-rc1"
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:0.14.449'
    }
}

allprojects {
    repositories {
        mavenCentral()
        jcenter()
    }
}

Here is my build.gradle in app dir:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {

    //Ommited for brevity

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
}

dependencies {
    compile 'org.jetbrains.kotlin:kotlin-stdlib:0.14.449'
}

I'm using Android studio 1.4,
buildToolsVersion 23.0.1,
Android studio kotlin plugin version 0.14.449.Idea141.12

like image 450
Mikhail Avatar asked Oct 19 '22 00:10

Mikhail


2 Answers

The current version of the databinding library is using kotlin. I believe the message you are seeing is because the library is using kotlin version 0.12.613.

There was a little bit of discussion about this on reddit.

You can try updating to the most recent version of the databinding library 1.0-rc4 to see if they've updated to M14 yet.

like image 54
eski Avatar answered Oct 24 '22 10:10

eski


Other answers cover the basics for this particular library. But in general:

About the error message...

The "unsupported format" error comes when the ABI version number of the class files created by Kotlin does not match the expected used by the Kotlin compiler. This is no longer an issue with Kotlin 1.0 Betas since the ABI number will not change again for 1.0. But, there will be one forced recompile at 1.0 release candidate to ensure no old compiler bugs affect libraries or code and everything is rebuilt clean. Afterwards no issues such as this will exist.

Therefore if a library is not up to date with the same ABI, or hits this last "1.0 recompile" you may run into a similar error. The solution is always to find the updated library.

More about this in the Kotlin 1.0 Beta 4 announcement "What's Next" section:

After the Beta period is over, there will an RC and then 1.0.

We would really like to make sure that no code compiled with pre-release versions of Kotlin are kept around after 1.0, so the RC compiler will force recompilation of all the old code. We will coordinate with library maintainers outside JetBrains to make sure that all the widely-used libraries will be recompiled in time.

We’ll also take the opportunity to remove some legacy at this point:

  • remove all the deprecations that we have accumulated in the process of evolving our libraries,
  • remove all the deprecations from the generated code (you might not have heard of those, but they exist!),
  • get rid of some legacy bytecode peculiarities that were found during the beta,
  • move some of the stdlib code around so that the packages there have more structure.

After that point, the only compatible changes to the standard library are deprecations and additions (this does not include reflection APIs). We are running an open review for the library API to make sure we haven’t missed anything important.

like image 25
Jayson Minard Avatar answered Oct 24 '22 12:10

Jayson Minard