Kotlin 1.2.20 is out

We’re happy to announce the release of Kotlin 1.2.20, a new bugfix and tooling update for Kotlin 1.2. This update:

  • Adds support for Gradle build cache
  • Improves incremental compilation for Android and mixed Kotlin/Java projects
  • Provides IDE support for the new Kotlin style guide
  • Adds inlay hints in the editor for implicit parameters and receivers of lambdas, as well as values returned from lambdas
  • Supports development mode in JavaScript DCE Gradle task
  • Introduces new inspections, performance improvements and bug fixes in the IntelliJ plugin

The update is compatible with all versions of IntelliJ IDEA from 2017.1 until 2017.3, as well as with Android Studio 3.0 and 3.1 Canary.

The complete list of changes in this release can be found in the changelog.

We’d like to thank our external contributors whose pull requests were included in this release: Toshiaki Kameyama (with an impressive number of contributions – 46 commits!), Yoshinori Isogai, Kenji Tomita, Kirill Rakhman, Sergey Ryabov, Alexey Belkov, Michal Bendowski, AdamMc331, Andre Perkins, Andrey Mischenko, Artem Zinnatullin, Chris Povirk, Denis Vnukov, Dereck Bridie, Ilya Zorin, Jake Wharton, Joscha Alisch, Kartik Patodi, AJ Alt, Ramon Wirsch, Vladimir Kasatkin, Yusuke Hosonuma, a2kaido, scache.

Compilation Performance Improvements

Compilation performance continues to be a major focus for us, and in this release we’ve mostly delivered improvements related to the Gradle plugin.

The first improvement is the support for Gradle build cache. If you’re using Gradle 4.3 or newer and the build cache is enabled (it’s not by default, requires --build-cache or org.gradle.caching=true), the plugin will reuse compilation results from previous executions of the Kotlin compile task. For example, if you build the master branch of your code, then switch to a different branch, build again, and switch back to master, the code will not be recompiled – previous results of master compilation will be reused.

Build caching for Kotlin annotation processors is disabled by default, because the dependencies of annotation processors cannot be tracked precisely by Gradle, so it may incorrectly reuse results of a previous execution of an annotation processors. To enable caching anyway, add the following lines to the build script:

The second improvement is more precise tracking of changes in Java files, allowing to avoid Kotlin recompilation when the changes in Java do not affect Kotlin code. This feature is experimental; to enable it, add the following line to your gradle.properties file:

Finally, changes to Android layout XML files no longer cause recompilation of all Kotlin sources; only Kotlin files that reference properties generated by Kotlin Android Extensions (kotlinx.android.synthetic.*) are recompiled.

Kotlin Style Guide

We’ve recently released a new official Kotlin style guide, covering the formatting of Kotlin code and the idiomatic use of language and library features. Since this version, the formatter fully supports the new style guide. Also, many style guide violations can be detected with IntelliJ IDEA inspections and corrected with quick fixes.

The formatting suggested by the new style guide is different in several aspects from the default formatting previously used by the Kotlin plugin. In order to avoid unwanted formatting changes, you need to apply the new style guide explicitly. In order to do that, go to Settings | Editor | Code Style | Kotlin and use the “Set from…” link to choose the code style.

Kotlin code style settings

IntelliJ IDEA Plugin Improvements

The new version of the plugin adds inlay editor hints for implicit parameters of lambdas, as well as for values returned from lambdas. The following screenshot illustrates both features in action.

Kotlin inlay hints

JavaScript DCE Development Mode

The JavaScript dead code elimination (DCE) plugin is used to reduce the output size of the Kotlin to JavaScript compiler. The DCE process takes a bit of extra time, and the output size does not matter during development, so it’s now possible to disable dead code elimination. This is done using the following option:

How to update

To update the plugin, use Tools | Kotlin | Configure Kotlin Plugin Updates and press the “Check for updates now” button. Also, don’t forget to update the compiler and standard library version in your Maven and Gradle build scripts.

As usual, if you run into any problems with the new release, you’re welcome to ask for help on the forums, on Slack (get an invite here), or to report issues in the issue tracker.

Let’s Kotlin!

This entry was posted in Releases and tagged . Bookmark the permalink.

58 Responses to Kotlin 1.2.20 is out

  1. Benjamin Kuchcik says:


    I tested naming convention but in a pure Kotlin project, I have a warning if i use the expected directory structure :
    In pure Kotlin projects, the recommended directory structure is to follow the package structure with the common root package omitted (e.g. if all the code in the project is in the "org.example.kotlin" package and its subpackages, files with the "org.example.kotlin" package should be placed directly under the source root, and files in "org.example.kotlin.foo.bar" should be in the "foo/bar" subdirectory of the source root).

    Is it implemented ? How do you detect that a project is pure Kotlin project ?

  2. Sankarsana das says:

    What about the plugin for kotlin?

    • Dmitry Jemerov says:

      What is your question specifically? The plugin is available, the blog post contains instructions for installing it.

      • Sankarsana das says:

        I have updeted in Android studio.
        In gradle – “ext.kotlin_version = ‘1.2.20’”.
        But i have warning – “Kotlin version that is used for building with Gradle (1.2.20) differs from the one bundled into the IDE plugin (1.2.10)”

  3. Luis Trigueiros says:

    When will the serialization support be integrated in idea?

    • Dmitry Jemerov says:

      What kind of integration are you interested in? At this time we have no plans to build any additional IDE features related to serialization.

  4. Tiago says:

    After setting up the new Kotlin Style Guide, there`s a way to revert to the old kotlin code style?

  5. Axrorxoja Yodgorov says:

    Good Jobs
    after update kotlin plugin 1.2.20 in AS 3.0.1 error when new project create not creating activity and .xml file.After downgrade it works normally

  6. Hans says:

    Great work! I really like the lambda parameter and “return” hints. :)

    Regarding the new style guide. Could you list or point me to a page mentioning the biggest differences between previous and current style?

    Best regards

    • Dmitry Jemerov says:

      Here you can see what settings are changed when you apply the new Kotlin style guide: https://github.com/JetBrains/kotlin/blob/master/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinStyleGuideCodeStyle.kt

      The biggest differences are 4-space indents in many places where previously 8-space indents were used (expression bodies, argument and parameter lists etc.) and the closing parenthesis being wrapped to a separate line in multiline expressions and declarations.

      • Hans says:

        Thank you! :)

        I kinda wonder why you chose to reduce the number of spaces for parameters from 8 to 4. I think having them at 8 spaces makes it easier to visually differentiate them from the super type / interface:

        I guess the reasoning was that an indent of 8 makes it too likely the maximum line width is reached.. Hmm.. how about using 2 spaces

        Despite that, the new style guide is looking great. Maybe I just have to get used to it.

        • Dmitry Jemerov says:

          The style guide actually contains an answer to your question. The change has nothing to do with line length; the motivation is consistency between primary constructor properties and properties declared in the class body.

          As for your concern, I think that classes with many superinterfaces that require wrapping are fairly uncommon; we haven’t seen many cases in our code where the optimal formatting looks like your example.

  7. K Abram says:

    Is there any plan to support static code analysis, specifically a PMD like tool that can be integrated into the build pipeline? This is a hurdle to adopt Kotlin for many shops.

  8. Scott Pierce says:

    What triggers the kapt build cache to invalidate? Can you help me understand the expected behavior a little better?

    • Alexey Tsvetkov says:

      There is no invalidation strategy specific for kapt. As far as I know Gradle allocates 5Gb locally for Build Cache, and removes older records when the limit is hit.

      Outputs are loaded from the cache only when inputs completely match something from the cache. Kapt runs in two steps:
      1. Kotlin classes are transformed into “Java stubs” (basically Java files with the same declarations, but without any method bodies, signatures only).
      2. Annotation processors are executed for actual Java sources and “stubs”. Only the source generation happens here, generated code is actually compiled in a “compileJava” task.
      The first step will hit the cache only when source files match completely. The second step will hit the cache only when signatures match completely.

      Note that caching is not enabled for kapt by default, so you would need to add kapt.useBuildCache = true to your build scripts.

  9. Anders says:

    Creating a standard project with kotlin + kotlin-js doesn’t work.

    Can’t load the kotlin2js extension, seems to conflict with the kotlin extension.

    Been trying to test the kotlin+js script stuff a few times now. But I’ve never been able to get the document/window stuff. I’m just generating it serverside, so I thought just loading the libraries would be enough but it seems not to be.

    • Dmitry Jemerov says:

      Indeed, you can’t use kotlin and kotlin-js in the same module. If you want to compile the same code to the JVM and Js, you need to create a multiplatform project: http://kotlinlang.org/docs/reference/multiplatform.html

      Not sure what exactly you mean by “the document/window stuff”, but you can’t reference JS declarations from server-side code. If you’re generating HTML on the server side, you can use kotlinx.html, which is supported for multiplatform projects.

  10. Christian says:

    The new style guide is really appreciated. However, I miss examples for chains of lambdas. If you are using libraries like Reactor you will need lots of lambda expressions following each other.

    myFlux.distinctUntilChanged { it.value }.map { it.value }.map { it * 2 }.filter { it in someListe }

    It looks a bit strange writing the next method directly after the closing curly brace. But a space here looks also unusual. I’d like to have a convention here.

  11. JustMe says:

    It would be great if you would make your position clear regarding the Eclipse/Netbeans plugins.

    I like Kotlin but I can’t really commit to it until I’ll have a properly maintained Eclipse or Netbeans plugin.
    And nobody is asking for a plugin with the same level of polish as the Idea one, but at least one that is builds / autocompletes correctly and is updated when the language itself changes.

    And again, I would understand if you decide not to do that, but at least make it clear, abandon those projects and maybe the community will pick them up.

    Thank you.

    • Dmitry Jemerov says:

      We’ve mentioned this explicity a few times already, and I can mention this again: For Eclipse, we’re currently working on resuming development, and we plan to continue providing an up-to-date and working plugin (even though feature parity with the plugin for IntelliJ IDEA is not a goal). For NetBeans, we have stopped working on the plugin and have no current plans to resume the work.

      • JustMe says:

        Thank you.

        My intention was just to let you know that there are developers out there (even though maybe not to vocal) that would like to work with Kotlin but are not ready/willing to change IDEs just yet.

        The rest is up to you :)

      • Sam Brannen says:

        Is there an issue we can follow in order to be automatically notified when the Eclipse plugin for Kotlin supports Kotlin 1.2.20+?

  12. Osahner says:

    Trying to run an Spring Boot Starter (JPA) App (2.0.0.M7):
    [org.springframework.boot.web.embedded.tomcat.TomcatStarter:62] Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name ‘webMetricsFilter’ defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsConfiguration.class]: Unsatisfied dependency expressed through method ‘webMetricsFilter’ parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘mvcHandlerMappingIntrospector’ defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘requestMappingHandlerMapping’ defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]: Factory method ‘requestMappingHandlerMapping’ threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘mvcConversionService’ defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method ‘mvcConversionService’ threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userRepository’: Cannot resolve reference to bean ‘jpaMappingContext’ while setting bean property ‘mappingContext’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘jpaMappingContext’: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: kotlin/reflect/jvm/internal/impl/load/kotlin/reflect/ReflectKotlinClass

    With 1.2.10 no problem

  13. larmic says:

    After upgrading from 1.2.10 to 1.2.20 @ConfigurationProperties with spring boot 2.0.0.M7 does not work anymore.
    With enabled validation a org.springframework.boot.context.properties.bind.validation.BindValidationException occurs.
    With disabled validation not properties will be injected.

  14. Alexander says:

    Documentation-generation needs much improvement. Dokka is severely lacking, atm, and doesn’t appear to be actively developed.

    • Dmitry Jemerov says:

      Actually right now Dokka is actively developed; it just doesn’t happen on the master branch. We plan to bring it to the 1.0 release fairly soon,

      • Eric Deandrea says:

        Seems that Dokka crashes when trying to document Kotlin 1.2 (Dokka Gradle plugin)

        java.lang.NoSuchMethodError: kotlin.reflect.jvm.internal.KClassImpl.getMembers(Lkotlin/reflect/jvm/internal/impl/resolve/scopes/MemberScope;ZZZ)Lkotlin/sequences/Sequence;
        at kotlin.reflect.KClasses.getMemberProperties(KClasses.kt:140)
        at org.jetbrains.dokka.ReflectDsl$CallOrPropAccess$prop$2.invoke(ReflectDsl.kt:22)
        at org.jetbrains.dokka.ReflectDsl$CallOrPropAccess$prop$2.invoke(ReflectDsl.kt:8)
        at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:130)
        at org.jetbrains.dokka.ReflectDsl$CallOrPropAccess.getProp(ReflectDsl.kt)
        at org.jetbrains.dokka.ReflectDsl$CallOrPropAccess.v(ReflectDsl.kt:30)
        at org.jetbrains.dokka.ReflectDsl$CallOrPropAccess.get(ReflectDsl.kt:18)
        at org.jetbrains.dokka.gradle.DokkaTask.extractClasspathAndSourceRootsFromKotlinTasks(main.kt:216)
        at org.jetbrains.dokka.gradle.DokkaTask.access$extractClasspathAndSourceRootsFromKotlinTasks(main.kt:54)
        at org.jetbrains.dokka.gradle.DokkaTask$kotlinCompileBasedClasspathAndSourceRoots$2.invoke(main.kt:116)
        at org.jetbrains.dokka.gradle.DokkaTask$kotlinCompileBasedClasspathAndSourceRoots$2.invoke(main.kt:54)
        at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:130)
        at org.jetbrains.dokka.gradle.DokkaTask.getKotlinCompileBasedClasspathAndSourceRoots$gradle_plugin_main(main.kt)
        at org.gradle.api.internal.tasks.properties.DefaultPropertyWalker$DefaultPropertyValue$1$1.create(DefaultPropertyWalker.java:138)
        at org.gradle.util.SingleMessageLogger.whileDisabled(SingleMessageLogger.java:240)
        at org.gradle.api.internal.tasks.properties.DefaultPropertyWalker$DefaultPropertyValue$1.get(DefaultPropertyWalker.java:135)
        at com.google.common.base.Suppliers$MemoizingSupplier.get(Suppliers.java:125)
        at org.gradle.api.internal.tasks.properties.DefaultPropertyWalker$DefaultPropertyValue.getValue(DefaultPropertyWalker.java:187)
        at org.gradle.api.internal.tasks.properties.DefaultPropertyWalker$DefaultPropertyValue.validate(DefaultPropertyWalker.java:198)
        at org.gradle.api.internal.tasks.DefaultTaskInputPropertySpec.validate(DefaultTaskInputPropertySpec.java:61)
        at org.gradle.api.internal.tasks.execution.DefaultTaskProperties.validate(DefaultTaskProperties.java:193)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:47)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
        at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:88)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:623)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:578)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)

  15. Antoni says:

    Would it be possible to add parameter type hint also to named lambda parameters?
    eg if I write x.sortedBy { sortField -> … } to have IDE show me type of sortField ?

    This is how it works in AppCode, unfortunately current implementation in Kotlin, while very welcome, is working only for implicit (unnamed) parameters

  16. banxi says:

    Got compile error after upgrade to kotlin 1.2.20

    Caused by: com.android.builder.merge.DuplicateRelativeFileException: More than one file was found with OS independent path ‘google/protobuf/descriptor.proto’

    and It seems it’s included in kotlin-reflect-1.2.20 lib

  17. Antonel-Ernest Pazargic says:


    Recently it was announced that kotlin 1.2.21 is out.
    I updated the gradle so as to use this version and then I tried to update the kotlin idea plugin.
    But, 1.2.20 is still the last stable kotlin plugin version.
    Is this normal?
    Up until now I noticed the versions were in sync, considering the version number.

    Kind regards.

  18. Antonel-Ernest Pazargic says:


    Please disregard my previous comment.
    It was one day delay between the availability of kt and kt idea plugin.
    Problem solved!


  19. Jouny says:

    The Best languague in the world

  20. Renato Garcia says:

    Hello, Is there any news for plugin Kapt work with Java 9?
    I am trying to migrate the kotlin project, but there is dependence that uses the kapt plugin and it doesn’t work with jdk 9.


  21. Jayson says:

    Is the image with the IDE hint for values returned from lambdas a hint that the hat ^ operator might be making a comeback? oh please oh please oh please….

    • Dmitry Jemerov says:

      It’s making a comeback in the form of this IDE feature. I don’t think there’s any chance that it will appear in the language itself.

  22. Vasyl Rudas says:

    New Code Style is good, but what about Gradle plugin option that enable it by default, to force all old/new developers of project use it, instead of manual setup in IDE(possible to avoid different Code Styles in project)?

Comments are closed.