Today is the beginning of KotlinConf.
It’s been almost 6 months since we announced Kotlin as a first-class language
for Android at Google I/O. During this period, the number of apps on Google Play
using Kotlin has more than doubled. More than 17% of the projects in Android
Studio 3.0 are now using Kotlin. We are really excited about the strong
momentum, and we are thrilled that Android developers all over the world are
discovering the joy of Kotlin programming.
Kotlin for Android is production-ready. From startups to Fortune 500 companies,
developers are already using Kotlin to build their apps. Developers from
Pinterest, to Expedia, to Basecamp R12; and many others R12; are finding their use
of Kotlin is increasing productivity and their overall developer happiness
levels. Take a look at some of their experiences with Kotlin below.
With the recent release of Android Studio 3.0,
there is now a stable version of our IDE that has Kotlin support built-in. With
Library 27, we have started adding nullability annotations to make the APIs
friendlier to use in Kotlin. We recently published the Android Kotlin Guides on
GitHub to provide some guidance for Android Kotlin style and interop. We
have also been porting some of our Android
samples to Kotlin, and we are adding Kotlin to our official documentation.
Android Studio 3.0
Last week, we released
Android Studio 3.0 on the stable channel. This is the first stable release
of Android Studio that has Kotlin support built-in. Building on the strength of
IntelliJ’s Kotlin support, many critical IDE features like code completion and
syntax highlighting work well for Kotlin. You can choose to convert Java code to
Kotlin by using Code → Convert Java File to Kotlin
File, or you can convert snippets of code just by pasting Java code
into a Kotlin file.
Project and code templates have also been updated with Kotlin support. When you
create a new project or add a new code file, you can choose Kotlin as one of the
The tooling experience with Kotlin is by no means perfect yet. We are aware of
issues, and we will continue to improve the IDE support for Kotlin in future
Android Kotlin Guides
There are two separate Android Kotlin Guides:
– details a set of rules and coding standards that Google recommends when
writing Kotlin for Android. The guide addresses naming conventions, formatting,
structure of the source contents, and much more.
guide – provides a set of rules for creating APIs in the Java and Kotlin
programming languages, so that the consuming code in the other language will
Null-safety is an important feature of the Kotlin language. It helps developers
avoid NullPointerExceptions and improves the quality of their apps. Null-safety
is a bit more complicated when using Java code from Kotlin. Since any reference
in Java may be null, Kotlin’s requirement for strict null-safety becomes
impractical for Java objects. Types declared in Java that do not contain
nullability annotations are called platform types – this means the Kotlin
compiler does not know whether it is nullable or not. When calling methods with
variables of platform types, the Kotlin compiler relaxes null-safety checks.
That means the overall null-safety of your app is weakened.
To let developers take more advantage of Kotlin’s strict null-safety, we have
started adding nullability annotations in Support
Library 27. The Support Library contains a huge API surface area, and we
will continue to expand the nullability annotation coverage in the next several
releases. In addition, we will also be adding nullability annotations to other
Android APIs over time.
While the Kotlin adoption growth is fantastic, our commitment to the Java and
C++ programming languages remains unchanged. We’ve added Java 8
language features support in Android Studio 3.0, and we’ve added more Java
8 language APIs in Android Oreo. We are also continuing to improve our
support for C++17 in the NDK. So even if you are not using Kotlin, your language
support will continue to improve.
It’s an exciting time to be an Android developer. If you haven’t had a chance to
try Kotlin, you can get started by learning the basic syntax
and by playing with the excellent Kotlin
Koans. When you are ready to use Kotlin in your Android app, you can jump to
the Android Kotlin page for
more resources. With Kotlin’s Java interoperability and Android Studio’s Java to
Kotlin converter, it’s easy to start using Kotlin in your project.