Tag Archives: KotlinConf

Google @ KotlinConf 2024: A Look Inside Multiplatform Development with KMP and more

Posted by Murat Yener – Developer Relations Engineer

Following our recent Google I/O announcement recommending Kotlin Multiplatform (KMP) for sharing business logic across mobile, web, server, and desktop platforms, and our move to use KMP in Google Workspace, KotlinConf 2024 was the next moment to share the highlights and connect with the Kotlin community.

Kotlin Multiplatform, developed by JetBrains, allows developers to build cross-platform apps by compiling Kotlin code into platform-native binaries while leveraging the full capabilities of a modern, memory-managed language. This approach has been a long-term investment for the Google Workspace team, enabling them to share the business logic between different platforms.

The Android team has been working to support KMP and recently released an alpha version of Room with KMP support. As of today, Annotations, Collections and DataStore are already in stable with KMP support . We've also commonified Lifecycle, ViewModel and Paging libraries to allow integrations with non-Android platforms.

Keynotes and Technical Sessions

The conference kicked off with a keynote, as part of which, Google’s Jeffrey van Gogh gave an overview of Google’s contributions to the Kotlin ecosystem. As part of this, Jeffrey delved into how Google leverages Kotlin Multiplatform (KMP) to streamline development across its own product portfolio. Jeffrey highlighted the benefits of code sharing and efficiency that KMP brings to Google's projects, aligning with our recent recommendations for Android app development.

Our technical sessions at KotlinConf 2024 span a range of topics:

  • A Tale of Two Languages by John Pampuch offered an engaging comparison of Java and Kotlin's evolution, highlighting their symbiotic relationship and mutual influence.
  • The Android Jetpack team, represented by Elif Bilgin, Yigit Boyar, and Daniel Santiago Rivera, unveiled Enabling Kotlin Multiplatform Success: The Android Jetpack Journey. They provided insights into the current state of KMP in Jetpack, shared updates on KMP-enabled Jetpack libraries, and explored the migration process of a well-established Jetpack library to KMP.
  • Going Fast with Kotlin by Andrei Shikov shared valuable insights gained from optimizing Compose for Android. Andrei highlighted interesting performance nuances in Kotlin and the guardrails the Compose team established to ensure optimal performance.
  • Kotlin Multiplatform in Google Workspace by Jason Parachoniak discussed Google Workspace's ongoing migration from a Java-oriented multiplatform foundation to Kotlin Multiplatform, aligning with Google's broader adoption of KMP. Jason shared lessons learned and the current state of this ambitious transition.
  • Write Your Own Kotlin Lint Checks! by Tor Norbye, Android Studio Engineering Director, empowered developers to extend Android Lint, a static analysis tool used by millions, by creating their own checks. Despite the name, it's not actually Android specific -- it's also used to analyze server Kotlin and Java code inside of Google!

Community Engagement at KotlinConf

We are always looking into ways to be actively engaged with the Kotlin community. If you attended KotlinConf, we hope you got a chance to check out our booth, with opportunities to chat with our engineers, get your questions answered, and learn more about how you can leverage Kotlin and KMP.

Learn more about KMP

In addition, you can view updated docs and a new mobile sample on KMP. These resources should have what you need to start learning KMP and if you have any feedback or come across any issues, please share them through this link.

Looking Ahead

We are excited about the future of Kotlin and are planning to add KMP support to more AndroidX libraries. We are looking forward to seeing how you will adopt and build the next generation of apps using KMP.

Thanks to KotlinConf organizers, speakers, attendees, and the entire Kotlin community for making this event happen and bringing Kotlin enthusiasts together.

Kotlin DSL is Now the Default for New Gradle Builds

Posted by James Ward, Product Manager, Kotlin and Boris Farber, Developer Relations Engineer

Android has been Kotlin-first for four years and many Android developers have made the switch resulting in higher productivity and more stable apps. However the default language to define builds has been Groovy (build.gradle), even though a Kotlin (build.gradle.kts) option has existed in Gradle for a number of years.

Today we're excited to announce that we're switching the default language for build scripts to Kotlin! This means that Kotlin is the single default language used for all project code, including UI with Jetpack Compose, and now build scripts! We've been working with the Gradle and JetBrains teams on this improvement, and you can read more in their related announcements: Gradle Blog; JetBrains Blog.

This doesn’t affect existing projects using Groovy, as those will continue working with no plans for deprecation. But if you are creating new projects or modules starting from Android Studio Giraffe, you now get the Kotlin DSL by default. The updated project templates are an easy way to get started with the new Kotlin DSL build scripts. To migrate existing builds, check out the Kotlin DSL migration guide.

While the Kotlin DSL is the default for new projects, large, existing Groovy DSL based projects should wait on migrating while Gradle, JetBrains, and Google work on improving build performance further. This work is ongoing and we will share updates as we make progress. Specifically, script compilation performance is slower than with the Groovy DSL. However, unlike with the Groovy DSL, the Kotlin DSL script compilation results are stored in Gradle local and remote caches so that subsequent builds do not need recompilation.

Having a single language for all code in a project isn't the only benefit to this change, so let's look at some other great things about using the Kotlin DSL for Gradle builds.

  • Kotlin is statically typed so you get quick and accurate code hints while editing Kotlin DSL build scripts:
  • Syntax errors are more accurate, and they’re displayed while editing Kotlin DSL build scripts, instead of when trying to sync the project:
  • Get type and method documentation by pressing Control+Q (Command+B on macOS).If you need more details you can go to the underlying source code by pressing Control+Click (Command+Click):
  • You can mix Groovy DSL build scripts and Kotlin DSL build scripts in one project and migrate incrementally module by module. This enables new modules to use the Kotlin DSL while keeping existing modules on Groovy.

An associated change we are also making to the New Project templates is an experimental option to use Gradle Version Catalogs with Kotlin DSL build scripts.

Version Catalogs give you a centralized, scalable way of defining your project’s dependencies. While using Version Catalogs is optional, they pair great with the Kotlin DSL by providing more type safety in your build definitions.

To learn about migrating to Version Catalogs, check out the migration guide.

The new Kotlin DSL default change is available now in Android Studio Giraffe previews. Please try it and let us know how it goes!

Google at KotlinConf ‘23

Posted by Márton Braun, Developer Relations Engineer

As part of Google’s ongoing commitment to supporting the Kotlin language, we are really excited to be a gold level sponsor for KotlinConf again this year. Grace Kloba shared the story of Google’s investments in Kotlin within the keynote, which is recapped in this post. You’ll also find the list of talks by Google from the event’s schedule below, make sure you catch these on the live stream.

For a summary of all KotlinConf keynote announcements, read the blog post by JetBrains.

Kotlin for Android

Kotlin started gaining popularity in the Android community around 2016. We were also impressed with Kotlin’s concise syntax, modern features, and safety. In 2017, we announced official support for Kotlin on Android, and committed to its future by creating the Kotlin Foundation with JetBrains.

Since then we invested in Kotlin by adding support in Android Studio, teaching the language to developers, and going Kotlin-first with our libraries, documentation, and samples. We also built Kotlin Symbol Processing, an API that enables annotation processors to run up to twice as fast as previous solutions.

Today, Kotlin is the most popular language for Android development. Over 95% of the top 1000 Android apps use Kotlin, and over 50% of professional Android developers use Kotlin as their primary language (compared with 25% choosing the Java programming language).

Among professional Android developers using Kotlin, we saw a 96.9% positive satisfaction rate in our latest annual survey, which is 9-points higher than their Java counterparts.

As our final step in making Kotlin the single language for Android development, we’re excited to announce today that the Gradle Kotlin DSL is becoming the default build language for Android apps, starting in Android Studio Giraffe. Read the blog post to learn more.

Jetpack Compose

Since going Kotlin-first, all new Jetpack libraries are written in Kotlin. Jetpack Compose, our modern toolkit for building Android apps, is Kotlin-only. It makes extensive use of Kotlin’s language features, and its implementation is made possible by Kotlin’s rich compiler API, which allows us to generate state management logic for you.

Jetpack Compose is changing the way developers build apps. The team from Clue shared with us that their development speed increased up to 3x after rewriting their app in Compose. Over 23% of the top 1000 Android apps ship with Compose, more than double year over year.

There are many resources available to learn Compose. For existing Android developers looking to expand their knowledge, we’ve published the Jetpack Compose for Android Developers course. For beginners to programming, we recommend taking the Android Basics with Compose course to learn Kotlin, Android, and Compose.

Kotlin at Google

Kotlin became generally available for Android development within Google in 2019. Since then, most of our Android apps are being built with Kotlin. As an example of the benefits, when the Google Home team migrated to Kotlin they saw a 33% decrease in NullPointerExceptions, which greatly improved the end user experience.

However, Google’s interest in Kotlin does not stop at Android apps. More than 45% of our engineers who write Kotlin use it for server development. We have over 15 million lines of Kotlin code in Google’s source control system, and this has been doubling year over year.

To support this, we have a dedicated team building tools to integrate Kotlin into Google’s ecosystem. You can catch the Adopting Kotlin at Google scale session for more details.

We’re looking forward to the new compiler in Kotlin 2.0, which will be a major improvement for developer productivity. We have a dedicated team working with JetBrains on the compiler, and we’re working to incorporate it into our tooling, including Android Studio, KSP, and the Compose compiler. We’re also leveraging our large internal codebase of Kotlin code to verify the compatibility of the new compiler.

Multiplatform

Looking forward, we are experimenting with Kotlin Multiplatform. This includes the Google Workspace team, who have a prototype with the business logic of Google Docs running on iOS using Kotlin Multiplatform and Kotlin/Native. Check out the Kotlin Multiplatform in Google Workspace lightning talk to learn more.

As part of our explorations into Kotlin Multiplatform, we’ve also made contributions that will benefit the community:

  • We’ve ported a set of Jetpack libraries to multiplatform. This allows you to use tools and APIs you know and love from Android and apply them to multiplatform. 
  • We’ve contributed to the Kotlin/Native toolchain, improving its performance. 
  • We’ve been helping out with the Gradle plugin for Kotlin Multiplatform, to give you more control over each target platform while still sharing as much code as possible.

Kotlin Foundation

As a founding member of the Kotlin Foundation, we’re excited about the Foundation’s expansions announced at KotlinConf:

  • Inviting more companies to collaborate on the development and promotion of Kotlin through a membership program
  • Offering funding for individual authors of actively maintained, open source Kotlin Multiplatform libraries.

With these steps, we continue to foster a healthy ecosystem for the language, and ensure its future advancement.

Catch us at KotlinConf

We look forward to sharing more in our sessions at KotlinConf, which you can tune in to on the live stream. If you’re attending in person, you can also visit us at our booth to have a chat about Kotlin.

April 13 schedule

Adopting Kotlin at Google scale
Jeffrey van Gogh, John Pampuch

Spring + Kotlin = Modern + Reactive + Productive
Josh Long, James Ward

Kotlin Multiplatform in Google Workspace
Jason Parachoniak

Kotlin Multiplatform Conversions at Android Jetpack Scale
Dustin Lam, James Ward

Untangling Coroutine Testing
Márton Braun

Adventures building a Kotlin Multiplatform Benchmarking Library
Rahul Ravikumar

April 14 schedule

Tracing coroutines in the JVM
Tyson Henning

Preventing Data Races in Async Coroutines
Kevin Bierhoff

Avoiding common coroutines mistakes in Compose
Márton Braun

*Java is a trademark or registered trademark of Oracle and/or its affiliates.

What’s new in multiplatform Jetpack libraries

Posted by Márton Braun, Developer Relations Engineer

To support developers who are already using Kotlin Multiplatform for sharing business logic across mobile platforms, we previously released experimental multiplatform previews of the Collections and DataStore Jetpack libraries, and we've been receiving great feedback from the community.

The multiplatform Collections and DataStore libraries are now moving from experimental developer previews to alpha releases, and will follow the normal release cycle of Jetpack libraries. Annotations, a core Jetpack library, is now also available for multiplatform.

Please note that Kotlin Multiplatform is still in beta, therefore the non-Android targets of these libraries don’t have Jetpack’s usual stability guarantees.

The alpha releases are available from Google’s Maven repository. You can try them by adding the following dependencies to your Kotlin Multiplatform project:

val commonMain by getting { dependencies { implementation("androidx.annotation:annotation:1.7.0-alpha02") implementation("androidx.collection:collection:1.3.0-alpha04") // Lower-level APIs with support for custom serialization implementation("androidx.datastore:datastore-core-okio:1.1.0-alpha03") // Higher-level APIs for storing values of basic types implementation("androidx.datastore:datastore-preferences-core:1.1.0-alpha03") } }

The multiplatform DiceRoller sample app has also been updated to use the new alpha version of DataStore.

To provide feedback on these multiplatform releases, create a bug on our issue tracker, or join the conversation in the Kotlinlang #multiplatform channel.

Android’s commitment to Kotlin

Posted by David Winer, Kotlin Product Manager

Android and Kotlin banner

When we announced Kotlin as a supported language for Android, there was a tremendous amount of excitement among developers. Since then, there has been a steady increase in the number of developers using Kotlin. Today, we’re proud to say nearly 60% of the top 1,000 Android apps contain Kotlin code, with more and more Android developers introducing safer and more concise code using Kotlin.

During this year’s I/O, we announced that Android development will be Kotlin-first, and we’ve stood by that commitment. This is one of the reasons why Android is the gold partner for this year’s KotlinConf.

Seamless Kotlin on Android

In 2019, we focused on making programming in Kotlin on Android a seamless experience, with modern Kotlin-first APIs across the Android platform. Earlier this year, we launched a developer preview of Jetpack Compose, a modern UI toolkit for Android built using a Kotlin domain-specific language (DSL). We also incorporated coroutines into several of the flagship Jetpack libraries, including Room and Lifecycle. Finally, we brought Kotlin extensions (KTX) to even more major Google libraries, including Firebase and Play Core.

On the tooling side, we strengthened our commitment to Kotlin in Android Studio and the Android build pipeline. Significant updates to R8 (the code shrinker for Android) brought the ability to detect and handle Kotlin-specific bytecode patterns. Support was added for .kts Gradle build scripts in Android Studio, along with improved Kotlin support in Dagger. We worked closely with the JetBrains team to optimize support for the Kotlin plugin, and make the Kotlin editing experience in Android Studio fluid and fast.

Better Kotlin learning

This year we’ve also invested in quality Kotlin on Android learning content.

We released two free video learning courses in partnership with Udacity: Developing Android Apps in Kotlin and Advanced Android in Kotlin. This content was also released as the Codelab courses Android Kotlin Fundamentals and Advanced Android in Kotlin, for those who prefer text-based learning. The popular Kotlin Bootcamp for Programmers Udacity course was also published as a Codelabs course, helping provide a Kotlin foundation for non-Kotlin developers. Kotlin-based instructional Codelabs were also created for topics including Material Design, Kotlin coroutines, location, refactoring to Kotlin, billing in Kotlin, and Google Pay in Kotlin. It hasn’t been just about new content: we've updated Kotlin Codelab favorites to take advantage of important features such as coroutines.

Looking ahead

In 2020, Android development will continue to be Kotlin-first. We’ve been listening to your feedback, and will continue partnering with JetBrains to improve your experience with Kotlin.

This includes working with JetBrains to improve the Kotlin compiler over the next year. Our teams are making the compiler more extensible with a new backend, and making your builds faster with a significantly faster frontend. We’re also working with many of the largest annotation processors to make compilation faster for Kotlin code. You can also expect more Kotlin-first updates to Android, including more Jetpack libraries that make use of Kotlin features such as coroutines.

Thank you for letting us be part of your app development journey this year. We look forward to continuing the journey with you in 2020.