Early access program for Kotlin 1.2 has been started

We’re excited to announce the start of the early access program for Kotlin 1.2: today its first milestone release 1.2-M1 is out. This release enables by default new language features that were previously available in 1.1.x releases under experimental 1.2 language version setting. Also in the standard library you can preview the new API. The […]

Read More

Kotlin 1.1.3 is out

We’re happy to announce the release of Kotlin 1.1.3, a new bugfix and tooling update for Kotlin 1.1. The update brings a number of new IDE features, performance improvements in the compiler and IDE, efficiency improvements for generated bytecode, and lots of bugfixes. The update is compatible with all versions of IntelliJ IDEA from 2016.2 […]

Read More

Kotlin/Native v0.3 is out

We’re happy to announce the release of Kotlin/Native v0.3. We are going to the new lands! With the release of version v0.3 Windows is supported as both a compilation host and execution target, and Google Android devices as an execution target with native activities. So Windows API ‘Hello World’ may look as easy as: import […]

Read More

Kotlin Future Features Survey Results

With all the exciting recent events, we had to postpone the publication of the Future Features Survey results. Sorry about that. Better late than never, this blog post summarizes what we learned from the survey. To recap, the Future Features Survey ran in April and got about 850 replies. We would like to thank everyone […]

Read More

How to use Data Binding and Kotlin in Android Studio 3.0.0

I just started to use Android Studio 3.0.0, but every time I try to build my project I get this error: Error:Circular dependency between the following tasks: :app:compileDebugKotlin +— :app:dataBindingExportBuildInfoDebug | — :app:compileDebugKotlin (*) — :app:kaptDebugKotlin — :app:dataBindingExportBuildInfoDebug (*) (*) – details omitted (listed previously) I am using kapt “com.android.databinding:compiler:2.2.0” Before I was using androidProcessor […]

Read More

Kotlin on Android. Now official

Today, at the Google I/O keynote, the Android team announced first-class support for Kotlin. We believe this is a great step for Kotlin, and fantastic news for Android developers as well as the rest of our community. We’re thrilled with the opportunities this opens up. For Android developers, Kotlin support is a chance to use […]

Read More

What is the equivalent of Java static methods in Kotlin?

There is no static keyword in Kotlin. What is the best way to represent a static Java method in Kotlin? Solution You place the function in the “companion object”. So the java code like this: class Foo { public static int a() { return 1; } } will become class Foo { companion object { […]

Read More

Why do we use “companion object” as a kind of replacement for Java static fields in Kotlin?

What is the intended meaning of “companion object”? So far I have been using it just to replace Java’s static when I need it. I am confused with: Why is it called “companion”? Does it mean that to create multiple static properties, I have to group it together inside companion object block? To instantly create […]

Read More

Kotlin – Property initialization using “by lazy” vs. “lateinit”

In Kotlin if you don’t want to initiate a class property inside the constructor or in the top of the class body, you have basically these two options ( from the language reference): Lazy Initialization lazy() is a function that takes a lambda and returns an instance of Lazy which can serve as a delegate […]

Read More

How to convert a kotlin source file to a java source file

I have a Kotlin source file, but I want to translate it to Java. How can I convert Kotlin to Java source? Solution In IntelliJ or Android Studio, you just have to do the following to get java code from kotlin: Menu>Tools>Kotlin>Show Kotlin Bytecode Click on the Decompile button Copy the java code This question was reposted […]

Read More