Google I/O 2023 で発表された Kotlin の新機能について紹介
Copyright (C) 2020 Yahoo Japan Corporation. All Rights Reserved.情報区分 ※スライドマスターで編集してください©2023 Yahoo Japan Corporation All rights reserved.Introduction of new in Kotlin forAndroidYahoo Japan CorporationYuma Kanno
View Slide
©2023 Yahoo Japan Corporation All rights reserved.Introduction2Yuma Kannon Yahoo Japan Corporation (2020 ~)PayPay Flea Market AppAndroid Engineer
©2023 Yahoo Japan Corporation All rights reserved.• Kotlin is an officially supported language on Android (2017)• Android development is Kotlin-first (2019)Kotlin in Android3https://android-developers.googleblog.com/2022/08/celebrating-5-years-of-kotlin-on-android.html$FMFCSBUJOHZFBSTPG,PUMJOPO"OESPJE
©2023 Yahoo Japan Corporation All rights reserved.• Kotlin 2.0 integration in Android Studio (2024 ~)The Kotlin 2.0 compiler4Project Kotlin 1.8 compiler Kotlin 2.0 compiler ImprovementKotlin 5m 40s 2m 37s ~2.2xIntelliJ IDEA Ultimate 34m 15s 16m 59s ~2.0xCompiler performanceWhatʼs new in Kotlin for Android:https://io.google/2023/program/a3250bf1-dab1-4752-82bb-4412afb94d66/intl/ja/
©2023 Yahoo Japan Corporation All rights reserved.The Kotlin 2.0 compiler5Try the Kotlin 2.0 compiler
©2023 Yahoo Japan Corporation All rights reserved.Kotlin DSL6
©2023 Yahoo Japan Corporation All rights reserved.Until now,the default language to build scripts wasGroovy (build.gradle)Kotlin (build.gradle.kts) option also existed.7
©2023 Yahoo Japan Corporation All rights reserved.Announce that the default language for build scripts has been switch toKotlin!!Kotlin is the single default language used for all project codeSwitch the default language8,PUMJO%4-JT/PXUIF%FGBVMUGPS/FX(SBEMF#VJMETIUUQTBOESPJEEFWFMPQFSTHPPHMFCMPHDPNLPUMJOETMJTOPXEFGBVMUGPSOFXHSBEMFCVJMETIUNM
©2023 Yahoo Japan Corporation All rights reserved.1. Compile-time checking2. Better IDE experience3. Simplified, declarative plugin syntax4. A growing community of Kotlin developersBenefits of choosing the Kotlin DLS over Groovy DSL9
©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 isexecuted• Working in an IDE, an editor can highlight the errorsCompile-time checking10
©2023 Yahoo Japan Corporation All rights reserved.• Auto-completion and content assistance• Source code navigation• RefactoringBetter IDE experience11
©2023 Yahoo Japan Corporation All rights reserved.• When you apply Gradle plugins to a project, you need to specify only the pluginID• If you try to apply a plugin that doesnʼt exist, the IDE will show you a syntaxerrorSimplified, declarative plugin syntax12(SPPWZ%4- ,PUMJO%4-
©2023 Yahoo Japan Corporation All rights reserved.• Documentation• Forums• Blogs• Threads on social media• Online educational coursesA growing community of Kotlin developers13
©2023 Yahoo Japan Corporation All rights reserved.• Kotlin DSL is selected by default when creating a new project moduleAndroid Studio Giraffe14
©2023 Yahoo Japan Corporation All rights reserved.• Manage dependencies in one central location and share dependencies acrossmodules or projects• While using Version Catalogs is optional, they pair great with the Kotlin DSL byproviding ore type safety in your build definitionsGradle Version Catalogs15
©2023 Yahoo Japan Corporation All rights reserved.KSP16
©2023 Yahoo Japan Corporation All rights reserved.kapt (Kotlin Annotation Processing Tool)KSP (Kotlin Symbol Processing)KSP17KotlincodeJavastubsJavaAnnotationProcessorsKotlincodeJavaAnnotationProcessorsWhatʼs new in Kotlin for Android:https://io.google/2023/program/a3250bf1-dab1-4752-82bb-4412afb94d66/intl/ja/
©2023 Yahoo Japan Corporation All rights reserved.KSP support18Library SupportedRoom ◯Moshi ◯Dagger ×Hilt ×Glide ◯
©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• KSPSummary19
©2023 Yahoo Japan Corporation All rights reserved.Thank you for listening20