Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction of new in Kotlin for Android

Introduction of new in Kotlin for Android

Google I/O 2023 で発表された Kotlin の新機能について紹介

kanno yuma

June 02, 2023
Tweet

Transcript

  1. Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved. 情報区分

    ※スライドマスターで編集してください ©2023 Yahoo Japan Corporation All rights reserved. Introduction of new in Kotlin for Android Yahoo Japan Corporation Yuma Kanno
  2. ©2023 Yahoo Japan Corporation All rights reserved. Introduction 2 Yuma

    Kanno n Yahoo Japan Corporation (2020 ~) PayPay Flea Market App Android Engineer
  3. ©2023 Yahoo Japan Corporation All rights reserved. • Kotlin is

    an officially supported language on Android (2017) • Android development is Kotlin-first (2019) Kotlin in Android 3 https://android-developers.googleblog.com/2022/08/celebrating-5-years-of-kotlin-on-android.html $FMFCSBUJOHZFBSTPG,PUMJOPO"OESPJE 
  4. ©2023 Yahoo Japan Corporation All rights reserved. • Kotlin 2.0

    integration in Android Studio (2024 ~) The Kotlin 2.0 compiler 4 Project Kotlin 1.8 compiler Kotlin 2.0 compiler Improvement Kotlin 5m 40s 2m 37s ~2.2x IntelliJ IDEA Ultimate 34m 15s 16m 59s ~2.0x Compiler performance Whatʼs new in Kotlin for Android: https://io.google/2023/program/a3250bf1-dab1-4752-82bb-4412afb94d66/intl/ja/
  5. ©2023 Yahoo Japan Corporation All rights reserved. Until now, the

    default language to build scripts was Groovy (build.gradle) Kotlin (build.gradle.kts) option also existed. 7
  6. ©2023 Yahoo Japan Corporation All rights reserved. Announce that the

    default language for build scripts has been switch to Kotlin!! Kotlin is the single default language used for all project code Switch the default language 8 ,PUMJO%4-JT/PXUIF%FGBVMUGPS/FX(SBEMF#VJMET IUUQTBOESPJEEFWFMPQFSTHPPHMFCMPHDPNLPUMJOETMJTOPXEFGBVMUGPSOFXHSBEMFCVJMETIUNM
  7. ©2023 Yahoo Japan Corporation All rights reserved. 1. Compile-time checking

    2. Better IDE experience 3. Simplified, declarative plugin syntax 4. A growing community of Kotlin developers Benefits of choosing the Kotlin DLS over Groovy DSL 9
  8. ©2023 Yahoo Japan Corporation All rights reserved. • Groovy is

    a dynamic language while Kotlin is a statically typed • Build script errors might occur at compile time rather than at runtime • With dynamic type checking, errors are not detected until the build script is executed • Working in an IDE, an editor can highlight the errors Compile-time checking 10
  9. ©2023 Yahoo Japan Corporation All rights reserved. • Auto-completion and

    content assistance • Source code navigation • Refactoring Better IDE experience 11
  10. ©2023 Yahoo Japan Corporation All rights reserved. • When you

    apply Gradle plugins to a project, you need to specify only the plugin ID • If you try to apply a plugin that doesnʼt exist, the IDE will show you a syntax error Simplified, declarative plugin syntax 12 (SPPWZ%4- ,PUMJO%4-
  11. ©2023 Yahoo Japan Corporation All rights reserved. • Documentation •

    Forums • Blogs • Threads on social media • Online educational courses A growing community of Kotlin developers 13
  12. ©2023 Yahoo Japan Corporation All rights reserved. • Kotlin DSL

    is selected by default when creating a new project module Android Studio Giraffe 14
  13. ©2023 Yahoo Japan Corporation All rights reserved. • Manage dependencies

    in one central location and share dependencies across modules or projects • While using Version Catalogs is optional, they pair great with the Kotlin DSL by providing ore type safety in your build definitions Gradle Version Catalogs 15
  14. ©2023 Yahoo Japan Corporation All rights reserved. kapt (Kotlin Annotation

    Processing Tool) KSP (Kotlin Symbol Processing) KSP 17 Kotlin code Java stubs Java Annotation Processors Kotlin code Java Annotation Processors Whatʼs new in Kotlin for Android: https://io.google/2023/program/a3250bf1-dab1-4752-82bb-4412afb94d66/intl/ja/
  15. ©2023 Yahoo Japan Corporation All rights reserved. KSP support 18

    Library Supported Room ◯ Moshi ◯ Dagger × Hilt × Glide ◯
  16. ©2023 Yahoo Japan Corporation All rights reserved. • Kotlin 2.0

    compiler • Switch the default language for build scripts to Kotlin • Benefits of choosing the Kotlin DSL over Groovy DSL • Gradle Version Catalogs • KSP Summary 19