Kotlin complains about API version not supported

Viewed 6099

I'm relatively new to Kotlin.

I did create a test project, just the Hello World for now.

Compile/Package OK, then when I try to run the main.kt :

Kotlin: API version 1.1 is no longer supported; please, use version 1.2 or greater.

Is driving me nuts. Ok, here some info and things I did :

  • Ubuntu 18.04
  • IntelliJ Idea Ultimate 2020.3 - all plugins/libraries updated
  • Kotlin project created from Project --> Kotlin --> Console Application --> SDK 1.8 --> Maven (need to simulate another environment that has similar settings)

On Settings/Build/Kotlin Compiler I selected Language version 1.4

When building I have only some warnings and I did notice this one :

[WARNING] Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    /home/steve/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.1.1/kotlin-stdlib-1.1.1.jar (version 1.1)
    /home/steve/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.4.31/kotlin-stdlib-jdk8-1.4.31.jar (version 1.4)
    /home/steve/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.4.31/kotlin-stdlib-jdk7-1.4.31.jar (version 1.4)

So it seems is still importing a stdlib 1.1.1, I did try to remove manually it but without success, is always there. The POM only has this from jetbrains :

   <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-stdlib-jdk8</artifactId>
        <version>1.4.31</version>
    </dependency>

Can anybody please give me some suggestions about how to fix this kind of problem ?

Thanks

STeve


Ok, I did restart from scratch many times trying to identify the problem and I think I did it, i.e. I identified the problem but I don't have a solution.

Starting from scratch everything is working, however I need to add to the project some classes I created in other projects in order to test them. One of the class imported uses a library called khttp.

Well the moment I add this library as dependence in the project, even without adding any code that use it, screw up everything and I end up with the error :

Kotlin: API version 1.0 is no longer supported; please, use version 1.3 or greater.

The ONLY way I found so far to solve the problem is to remove from the POM the dependency of the library. So I guess that the problem is IN the library. If I can't find a solution I guess I need to don't use khttp.

Thanks

4 Answers

Go to Intellij Preferences -> Build, Execution, Deployment -> Compiler -> Kotlin Compiler. Update Language version and Api version to the one you wish.

**Click run again it should work fine.

enter image description here

for me it worked like this: right click on project and go to

 project settings -> modules -> Kotlin 

there I set the API Version to 1.5

I update the Kotlin dependencies version in pom.xml from 1.3.61 to 1.5.10 and it's ok for me

Project Structure>Modules>General
When you go there you gonna see 2 sections right side. Language version and API version. Update these 1.5 and problem will solve easily.

Related