Google、Room 3.0を発表:Kotlinファーストの非同期マルチプラットフォーム永続化ライブラリ
GoogleはAndroidの永続化ライブラリ「Room」をメジャーアップデートし、Kotlin Multiplatform対応とJavaScript/WebAssemblyプラットフォームの追加により、非同期処理を標準化するBreaking Changesを導入した。
キーポイント
メジャーアップデートと破壊的変更
Room 3.0は既存のAndroid永続化ライブラリを刷新し、主要なAPIで破壊的変更を導入した。
Kotlin Multiplatformへの完全統合
Kotlinファーストの設計方針を徹底し、マルチプラットフォーム開発におけるデータ永続化層の標準化を進めた。
JavaScriptとWebAssembly対応の追加
従来のAndroid限定から脱却し、ブラウザ環境やWebAssembly実行環境での利用を正式にサポートした。
影響分析・編集コメントを表示
影響分析
本アップデートはAndroid開発エコシステムにおけるデータ永続化の標準を再定義し、Kotlin Multiplatform戦略の実装を加速させる。破壊的変更は短期的な移行コストを生むものの、WebAssemblyやJS環境への展開を可能にすることで、エッジAIアプリケーションやクロスプラットフォームUIフレームワークの基盤技術として長期的な価値を持つ。
編集コメント
Android開発者にとってはマイグレーション作業が待ったなしだが、KMP対応とWebAssemblyサポートは将来のクロスプラットフォームAIアプリ開発において基盤となる重要な一歩である。技術選定の幅が広がり、ローカルデータ処理のパターンが見直されるだろう。
Room 3.0 is a major update to Android's persistence libraryが主要な領域で破壊的変更を導入するアップデートです。今回の新リリースは、Kotlin Multiplatformを中心にAndroidの永続化レイヤー(Persistence Layer)を近代化することに焦点を当て、JavaScriptおよびWebAssemblyを含むプラットフォームサポートも拡大しています。
Room 3.0における最大の変更点は、Javaコードの生成を廃止し、代わりにKotlinのみを生成するようになったことです。開発チームによれば、これによりコードベースと開発プロセスの両方が簡素化され、より高速なイテレーションが可能になります。
Javaコードの生成に加え、Room 3.0はJava Annotation Processing(AP)およびKAPTのサポートも削除します:
Room 3.0はKSP(Kotlin Symbol Processing)プロセッサのみとなり、Java言語に縛られることなくKotlinコードベースの処理をより最適に行えるようになります。
その結果、Room 3.0はJavaのみのコードベースであってもKSPおよびKotlinコンパイラの使用を必要とします。このような場合の推奨アプローチは、Roomの使用を1つの専用モジュール内に隔離することであり、「Kotlin Gradle PluginおよびKSPを適用しても、コードベースの他の部分に影響を与えないようにする」ことができます。
アーキテクチャの観点からは、2つの追加の破壊的変更が際立っています。それはAndroidネイティブのSQLiteデータベースAPI(SupportSQLite)の削除と、コルーチンファーストモデル(Coroutine-first model)の採用です。Android固有のAPIに依存するのではなく、Room 3.0はKMP互換のandroidx.sqlite driver APIsを使用しており、2つのSQLバックエンドを維持する必要がなくなることで開発が簡素化されています。
Kotlin coroutinesの採用により、完全な非同期操作が可能になりました。その結果、データを挿入、削除、またはクエリするなどのデータ操作を行うために生成されるすべてのDAO(Data Access Object)関数は、suspendとして定義されます。あるいは、Kotlin FLowを使用して複数の値を順次出力できるリアクティブ型を返すことも可能です。
開発者がRoom 3.0へ移行し、AndroidネイティブのSQL APIから離れることを容易にするため、Room 2.8.0はandroidx.room:room-sqlite-wrapperを導入しました。このアーティファクトは、RoomDatabaseをSupportSQLiteDatabaseに変換できる互換性レイヤーを提供します:
これは、コードベースの完全な移行により時間を要する開発者にとっての一時的な橋渡しを提供します。このアーティファクトは、Room 3.0においてもandroidx.room3:room3-sqlite-wrapperとして存続し、重要なSupportSQLiteの使用を維持しつつRoom 3.0への移行を可能にします。
前述の通り、Room 3.0はプラットフォームサポートをJavaScriptおよびWasmJSにも拡張しています。これにより複数の破壊的変更が導入されており、多くのRoom 3.0関数がWebストレージを適切にサポートするために本質的に非同期な*suspend*関数として定義され直しているためです。
SQLiteDriver(SQLite Driver)APIもWeb対応のために更新され、androidx.sqlite:sqlite-webにおいて新しい非同期Webドライバが利用可能になりました。これはWeb Workerベースのドライバであり、Origin private file system (OPFS)(Origin Private File System)にデータベースを永続化することを可能にします。
Room 3.0のリリースに伴い、Room 2はメンテナンスモード(maintenance mode)に入り、Room 3.0が安定するまで、バグ修正と依存関係の更新に限定されたパッチリリース(patch releases)(2.8.0ベース)のみが提供されます。
著者について
セルジオ・デ・シモーネ
セルジオ・デ・シモーネはソフトウェアエンジニアです。セルジオは、Siemens、HP、小さなスタートアップなど、多様なプロジェクトや企業で25年以上にわたりソフトウェアエンジニアとして活動してきました。過去10年以上は、モバイルプラットフォームおよび関連技術の開発に注力しています。現在は大規模ML企業BigML, Inc.で働き、iOSおよびmacOS開発をリードしています。
詳細を表示表示を閉じる
原文を表示
Room 3.0 is a major update to Android's persistence library that introduces breaking changes in key areas. The new release focuses on modernizing Android persistence layer around Kotlin Multiplatform and expands platform support to include JavaScript and WebAssembly.
The biggest change in Room 3.0 is that it will no longer generate Java code, producing only Kotlin instead. According to the development team, this simplifies both the codebase and the development process, enabling faster iterations.
Along with Java generation, Room 3.0 is also removes support for Java Annotation Processing (AP) and KAPT:
Room 3.0 is solely a KSP (Kotlin Symbol Processing) processor, allowing for better processing of Kotlin codebases without being limited by the Java language.
As a consequence, Room 3.0 requires the use of KSP and the Kotlin compiler, even for Java-only codebases. The recommended approach in such cases is to isolate Room usage within one dedicated module, so the "Kotlin Gradle Plugin and KSP can be applied without affecting the rest of the codebase".
From an architectural perspective, two additional breaking changes stand out: the removal of the Android’s native SQLite database API (SupportSQLite) and the adoption of a coroutine-first model. Instead of relying on the Android-only APIs, Room 3.0 uses the KMP-compatible androidx.sqlite driver APIs, simplifying development by eliminating the need to maintain two SQL backends.
The adoption of Kotlin coroutines enables fully asynchronous operations. As a result, all DAO functions generated by the library, such as to insert, delete, or query the data, are defined as suspend. Alternatively, they can return a reactive type using Kotlin FLow, capable of emitting multiple values sequentially.
To make it easier for developers to migrate to Room 3.0 and away from Android's native SQL API, Room 2.8.0 introduces androidx.room:room-sqlite-wrapper. This artifact provides a compatibility layer that allows you to convert a RoomDatabase into a SupportSQLiteDatabase:
This provides a temporary bridge for developers who need more time to fully migrate their codebase. This artifact continues to exist in Room 3.0 as androidx.room3:room3-sqlite-wrapper to enable the migration to Room 3.0 while still supporting critical SupportSQLite usage.
As mentioned, Room 3.0 also extends its platform support to JavaScript and WasmJS. This introduces several breaking changes, as many Room 3.0 functions are now *suspend* functions to properly support web storage, which is inherently asynchronous.
The SQLiteDriver APIs have also been updated to support the Web and a new web asynchronous driver is available in androidx.sqlite:sqlite-web. It is a Web Worker based driver that enables persisting the database in the Origin private file system (OPFS).
With the release of Room 3.0, Room 2 enters maintenance mode and will only receive patch releases on top of 2.8.0, limited to bug fixes and dependency updates, until Room 3.0 reaches stability.
About the Author
Sergio De Simone
Sergio De Simone is a software engineer. Sergio has been working as a software engineer for over twenty five years across a range of different projects and companies, including such different work environments as Siemens, HP, and small startups. For the last 10+ years, his focus has been on development for mobile platforms and related technologies. He is currently working for BigML, Inc., where he leads iOS and macOS development.
Show moreShow less
関連記事
Chrome拡張機能でTransformers.jsを使用する方法
開発者はChrome拡張機能にTransformers.jsを組み込み、ブラウザ上で機械学習モデルを実行する。これによりサーバー依存を排除し、プライバシー保護と低レイテンシを実現する実装手順を示す。
Google の Gemini 3.1 Flash TTS モデルによる自然な音声合成ツール
Google は、単一話者および複数話者の会話モードに対応し、発声指示タグの適用も可能な「Gemini 3.1 Flash TTS」モデルを公開した。このツールにより、テキストから自然な音声を生成してダウンロードできるようになった。
Google、Chromeを職場向けAIコワーカーに進化させる
Googleは企業向けChromeにGemini搭載の「自動閲覧」機能を追加し、従業員が調査やデータ入力などの業務を自動化できるようにした。