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

Other Decks in Programming

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

    View Slide

  2. ©2023 Yahoo Japan Corporation All rights reserved.
    Introduction
    2
    Yuma Kanno
    n Yahoo Japan Corporation (2020 ~)
    PayPay Flea Market App
    Android Engineer

    View Slide

  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

    View Slide

  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/

    View Slide

  5. ©2023 Yahoo Japan Corporation All rights reserved.
    The Kotlin 2.0 compiler
    5
    Try the Kotlin 2.0 compiler

    View Slide

  6. ©2023 Yahoo Japan Corporation All rights reserved.
    Kotlin DSL
    6

    View Slide

  7. ©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

    View Slide

  8. ©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

    View Slide

  9. ©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

    View Slide

  10. ©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

    View Slide

  11. ©2023 Yahoo Japan Corporation All rights reserved.
    • Auto-completion and content assistance
    • Source code navigation
    • Refactoring
    Better IDE experience
    11

    View Slide

  12. ©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-

    View Slide

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

    View Slide

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

    View Slide

  15. ©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

    View Slide

  16. ©2023 Yahoo Japan Corporation All rights reserved.
    KSP
    16

    View Slide

  17. ©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/

    View Slide

  18. ©2023 Yahoo Japan Corporation All rights reserved.
    KSP support
    18
    Library Supported
    Room ◯
    Moshi ◯
    Dagger ×
    Hilt ×
    Glide ◯

    View Slide

  19. ©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

    View Slide

  20. ©2023 Yahoo Japan Corporation All rights reserved.
    Thank you for listening
    20

    View Slide