5

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

4
  • The only thing I see here at first glance is that you're using jcenter() and not mavenCentral() Commented Oct 14, 2015 at 15:48
  • @Jeremy Thanks for noting that! I have just tried adding mavenCentral() but it hasn't helped. I cannot remove jcenter() because otherwise gradle cannot resolve databinding library. Commented Oct 14, 2015 at 15:54
  • jcenter should be fine as I have that in my project as well. Does your app's build.gradle also define the following as a top level function : repositories { mavenCentral() jcenter() } Commented Oct 14, 2015 at 15:56
  • @Jeremy I've just tried adding this and it hasn't helped as well (after syncing with gradle and cleaning/rebuilding project). Commented Oct 14, 2015 at 16:02

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Wow, thanks for the info, I'll have a look at it tomorrow.
If the reddit link has value, please edit your answer to include the relevant portion as a quote. As to the "why?" -- It is the version mismatch between the compiler the author of the question is using and the version of the library.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.