API Changes
- Added
AppFunctionServiceEntryPoint. All AppFunction annotation must be declared within theAppFunctionServicethat is annotated withAppFunctionServiceEntryPointIdc5d5 b/463909015 - Moved
AppFunctionandAppFunctionConfigurationAPIs .AppFunctionConfigurationwill be removed in future release as it will be replaced byAppFunctionServiceEntryPointIaff23 I4cf3e b/517876475 - Updated
AppFunctionServiceAPI to support callback I6e0d7 b/519880977 - Add
searchAppFunctionsAPI I8c0f9 I1fa27 b/494239238 - Added
functionNamestoAppFunctionSearchSpecI95f53 b/494239238 - Added
AppFunctionInstructionannotation I21120 b/488994214 - Added
AppFunctionSignatureannotation and accompanying constants to declare runtime registered app function signatures. I82a05 Ie2361 Ib6bb2
Bug Fixes
- Omit
enabledByDefaultfrom generated XML forAppFunctionSignaturesIe2996 b/501032667
API Changes
- Simplified Perfetto trace capture on device. I48810
- Move the experimental
TraceProcessor.runServerextension APIs fromandroidx.benchmark:benchmark-macrotoandroidx.benchmark:benchmark-common, and to theandroidx.benchmarkpackage. This will enable their use in microbenchmarks in the future. Ie25bb b/393640753
Bug Fixes
- Update traceprocessor implementation (as well as unbundled Perfetto Trace capture) to use Perfetto v56.0 I8fb9d
- Set
androidx.benchmark.requireAotandandroidx.benchmark.requireAotto true by default. These safer defaults ensure that compilation is performed ahead of running microbenchmarks (on by default with the benchmark gradle plugin when using AGP 8.4+), and thatmeasureRepeatedis not used on the main thread, where it can cause ANRs. I1bc3c b/379115078 - Increased perfetto kill timeout from 5 to 30 seconds (for benchmark captured Perfetto sessions only). Added clearer error logging when the issue occurs. If188f b/435589290
API Changes
CameraXViewfindernow supports built-in gestures for pinch-to-zoom and tap-to-focus, and adds support for screen flash and stream state.FocusStateis now public in viewfinder-core to allow monitoring tap-to-focus results. I66a17 b/522549890- Added
TransformationModeproperty toTransformationInfoto support apps to useOpenGLpipeline inEMBEDDEDmode. Id1de1 b/487826941
Bug Fixes
- Remove requirement for
compileSdk 37If78b4
API Changes
CameraXViewfindernow supports built-in gestures for pinch-to-zoom and tap-to-focus, and adds support for screen flash and stream state.FocusStateis now public in viewfinder-core to allow monitoring tap-to-focus results. I66a17 b/522549890- Added
isAutoRotationEnabledtoSessionConfig.Builder,HighSpeedVideoSessionConfig.Builder,ExtensionSessionConfig.Builderand introduced a Kotlin DSL factory functions for them. This allows setting the appropriate rotation automatically based on device sensors. I5b4a3 b/510752515 - Added
TransformationModeproperty toTransformationInfoto support apps to useOpenGLpipeline inEMBEDDEDmode. Id1de1 b/487826941 - Added
isNightModeIndicatorSupported()andgetNightModeIndicator()toCameraInfoto determine when the environment conditions meet the criteria for Night Mode. Iae47b b/499389465 - Exposed ImageAnalysis.OUTPUT_IMAGE_FORMAT_PRIVATE and ImageProxy.getHardwareBuffer() as public API to support GPU based ImageAnalysis. I41cb3 b/496022391 b/492934501
- ExtensionsManager#getExtensionEnabledCameraSelector is now deprecated. Please use the new ExtensionSessionConfig API for enabling extension modes. I2b336 b/473715607
- Added support for visual styling of camera frames during concurrent camera composition. You can now customize:
- Rounded Corners: Use setRoundedCornerRatio(float) to apply normalized rounding (0.0 to 1.0) to frame edges.
- Borders: Use setBorderWidthRatio(float) and setBorderColor(int) to add a decorative frame with consistent thickness I18a07 b/366349205
- Updated CompositionSettings to enforce non-negative z-order and added validation to ConcurrentCamera.setCompositionSettings to ensure it's called with the correct number of settings in a valid composition mode. If660d b/496951658
- Added getNightModeIndicator() and isNightModeIndicatorAvailable() to CameraExtensionsInfo to allow applications to monitor whether the current environment is in a night mode condition when using camera extensions. I62bb4 b/499389465
- Added support for
QHDvideo quality in VideoCapture. I0ac20 b/501305592 - Added
Recorder.Builder.setTargetAudioChannelCount(int)andRecorder.getTargetAudioChannelCount()to allow developers to set an explicit audio channel count. I6bee0 b/441895100 - Added
Recorder.Builder.setTargetAudioEncodingBitRate(int)to allow setting a target audio encoding bitrate. I29062 b/241151504 - Added the ConcurrentCamera.setCompositionSettings API to allow apps to update composition of the current camera dynamically after the lifecycle has been bound. Additionally, a new setZOrder API in CompositionSettings.Builder enables precise control over the rendering order of overlapping camera streams. I90528 b/473702287
- Introduced APIs for granular control over encoding formats. Developers can now discover device-supported formats using
Recorder.getSupportedVideoMimeTypes()andgetSupportedAudioMimeTypes(), which are currently experimental. Preferred formats can be explicitly configured viaRecorder.Builder.setVideoMimeType()andsetAudioMimeType(). Additionally,Recorder.getVideoCapabilities(CameraInfo, String)allows querying camera-specific capabilities, such as supported qualities and dynamic ranges, for a chosen codec. I4620e b/491319384 - Added CameraController.setAutoRotationEnabled(boolean) to allow disabling the automatic device rotation listener. Ia0c03 b/449573627
- Added AE/AWB locking support in FocusMeteringAction via a new setLockingMode API. This also allows updating 3A regions without locking focus, enabling the camera to remain in continuous autofocus mode while updating the focus area. I6416f b/481624745
Bug Fixes
- Remove requirement for
compileSdk 37If78b4 - Fixed
CameraXViewfindertransformation issues inEMBEDDEDmode whenOpenGLpipeline is enabled byCameraXfor binding moreUseCasesor surface processing. I3e637 b/487826941 - Updated tests and activities to use ExtensionSessionConfig instead of the deprecated getExtensionEnabledCameraSelector API. I765d8 b/473715607
- Fixed a compilation error "Cannot access class 'ListenableFuture'". Ic8cba b/497571473
- Updated Compose compileSdk to API 37. This means that a minimum AGP version of 9.2.0 is required when using Compose. Id45cd b/413674743
Features - expressive timepicker component Iaa45f - Added new non-interactive variants of standard list item and segmented list item which follow Material Expressive specifications. The non-expressive version has been deprecated. Ide4de b/491994186
Behavioral Change - Fix issue where minimum height of expressive list items did not change based on lines of content. The feature flag isExpressiveListItemHeightBasedOnTextLinesFixEnabled has been introduced to aid migration. Ibbb91 b/484693233
API Changes
- Expressive list item APIs are no longer experimental. I2836a
- Remove
ComponentOverrideAPIs I820c4 - Remove unused offset parameter from
DropdownMenuPopup. Added the default menu properties into the menu defaults. Updated the naming for groups label fromMenuDefaults.LabeltoMenuDefaults.DropdownMenuGroupLabel. AddeddisabledContainerColorintoMenuDefaults.selectableItemColorsandMenuDefaults.selectableItemVibrantColors. AddedModifierparameter to composable functions inMenuDefaultsthat return a layout. I3d2b1 - Added a public
flingAnimationSpecgetter toTopAppBarDefaultsto expose the default fling animation spec. Ic1daa - Graduate
TopAppBar,MediumFlexibleTopAppBar,LargeTopAppBar,LargeFlexibleTopAppBar,TwoRowsTopAppBar,FlexibleBottomAppBar,FlexibleContentPadding,FlexibleBottomAppBarHeight,FlexibleHorizontalArrangement,FlexibleFixedHorizontalArrangementto non-experimental. These APIs and variables no longer require the @ExperimentalMaterial3ExpressiveApiopt-in. Ia4af6 - Graduate
ExpandedDockedSearchBarWithGapandExpandedFullScreenContainedSearchBarto non-experimental Ie152d
Bug Fixes
- Cleans up API information Ia8066
- Fix
Scaffold's keyboard navigation order. I77194 b/462577176 - Remove requirement for
compileSdk 37If78b4 - Add a11y support for ScrollField component. More specifically, ScrollField now implements selectable and animates to the selected item on click with selected/unselected announcements in Talkback. I7bdb7
- Fix bug where there is extra bottom padding if the nav suite scaffold's content has ime padding set. I86d9d b/389467593
Bug Fixes
- Fixed an
ArrayIndexOutOfBoundsExceptionin theLinkComposerwhen using nestedMovableContent. I85daf
API Changes
BasicPictureInPictureandVideoPlaybackPictureInPictureclasses now require an Executor in their constructors. A new commit() method has been introduced and must be called to apply parameter changes. Ib9150 b/493673311
Bug Fixes
- Catch exception in
setPictureInPictureParamsIbfeb2 b/519706801
API Changes
- Add a
maxLifecycleparameter to theAndroidFragmentcomposable. This allows you to cap the lifecycle state of the embeddedFragment, giving you finer control over its behavior in complex UI setups like pagers or tabs. Ie99b5 b/526109804 - Fragment library now supports system tracing of the lifecycle event via Jetpack Tracing. Ibc63b b/112161409
API Changes
- Removed the permission check from
heartRateAccuracyI14269 b/522444636
Bug fixes
- We have tweaked the Squircle shaped Wear widget params for preview per UX feedback
Bug Fixes
- This library now uses JSpecify nullness annotations, which are type-use. Kotlin developers should use the following compiler arguments to enforce correct usage: -Xjspecify-annotations=strict, -Xtype-enhancement-improvements-strict-mode Ib5eb3 b/326456246
- Deprecated
androidx.core.os.CancellationSignal. Usages should be replaced with the platform-providedandroid.os.CancellationSignal. Id45f6 b/309499026 b/309054079
Bug Fixes
- Modified
handleDeepLinkto ensure only recognized deep links are handled Id4fe3 b/509640056 - Changed
ComposableFragmentto use the fully qualified name from the destination instead of a fragment argument to inflate composable functions. I65ded b/509640586 - Fixed a crash in
FragmentNavigatorthat caused legitimate Fragments to throw anIllegalArgumentExceptionwhen operations are optimized out. I093b0 b/340202276 - Fixed an error in Navigation with Fragments where setting the graph programmatically would fail to be restored properly. I41251 b/321147435
Bug Fixes
- Fixed popped entry disappearing immediately when popping to an entry that has a nested metadata containing lambda values. Idb872 b/520494430
New API
- Added a
rememberResultEventBusapi which returns aResultEventBusthat can be passed torememberResultEventBusNavEntryDecorator. This allows hoisting aResultEventBusoutside theResultEventBusNavEntryDecorator. Ia655b b/516995400
DeepLinkRequest
- Added two KMP-compatible constructors - one that takes a DeepLinkUri and one that takes a raw string uri. I3c088 b/513200887 b/522194187
- (Android only) Added a constructor that takes an
Intent. Ia0498 b/513200887 b/522194187 - All constructors have an additional
extrasfield for aMap<String, Any>to attach additional request information. If81d5 b/513200887 - A new
requestExtrasdsl is added as a type safe way to build a map of extras. The dsl provides aputfunction to store pairs ofRequestExtrasKeytoAny. TheMap<String, Any>.get(key)extension function can be used to read from the map with aRequestExtrasKeyI5091c b/513200887 - (Android only) Added an
ActionExtrasKeyandactionExtrafunction to create an extras map withActionExtrasKey. (Id0c90, [b/513200887] - Added a
MimeTypeExtrasKeyandmimeTypeExtrafunction to create an extras map withMimeTypeExtrasKey. I85131 b/513200887
DeepLinkMatcher
- Added
DeepLinkMatcher.mimeTypeFilterandDeepLinkMatcher.actionFilterfunctions to createDeepLinkMatcher.Filtersthat filterDeepLinkRequestbymimeTypeoraction(Android only). Both filters match by string equality and is case-insensitive. Ie7e67 b/513191950
API Changes
DeepLinkRequest
- Remove
fromActionfactory function. To create a request associated with an Action, use the newDeepLinkRequest.extrasfield.Id0c90 b/513200887 - Removed
fromMimeTypefactory function. To create a request associated with a mimeType, use the newDeepLinkRequest.extrasfield. I85131 b/513200887 - (Android-only) Removed
fromIntentfactory function. Replaced by a new constructor that takes an Intent and extras map. Ia0498 b/513200887 b/522194187 - Removed factory functions
fromUriandfromUriString. Replaced by new constructors that either take aDeepLinkUrior a raw string uri. Id5b6f b/522194187 DeepLinkMatcher,DeepLinkMatcher.MatchResultand their subclasses now take a covariant T (out T) so that hierarchical keys will not need type casting with used with Matchers. I1e453 b/525094876- The
UriMatchResultconstructor param for arguments map now defaults to an empty map. I3acdd DeepLinkMatcher.Filterabstract class is now a functional interface. Thefilterconstructor field is removed and instead should be passed directly in the subclass. I9eb7d b/522194187
Bug Fixes
- Fixed popped entry disappearing immediately when popping to an entry that has a nested metadata containing lambda values. Idb872 b/520494430
- Fixed
UriDeepLinkMatcherso that it will return a nullUriMatchResultinstead of throwingMissingFieldExceptionwhen required arguments are missing during matching. I5322f b/524663005 - A
UriDeeplinkMatchercontaining uri with https scheme can only be matched with requests that also have https scheme. Ibfe22 b/522304329 - Fix
UriDeepLinkMatcherto correctly identifyhttpscheme as a positive match withhttpswhen matching aDeepLinkRequestto aUriDeepLinkMatcher. I3a62b b/518804264 DeepLinkMatcher.MatchResultcomparator now returns 0 by default when two results are equal. I48ddb b/518841353UriDeepLinkMatcherwill now return a nullUriMatchResultinstead of throwing an exception when match request fails due to missing required arguments. I669a7 b/470282247 b/512923412
API Changes
androidx.benchmarknow has aminSdkof 24. Ic2a85- Add onForwardCompletedFallback to TestNavigationEventDispatcherOwner to enable tracking and testing of unhandled forward navigation events. I6bbd7
- Add navigationEventInput to TestNavigationEventDispatcherOwner to simplify simulating navigation events in tests. I3ef48
Bug Fixes
- Cleans up API information Ia8066
- Ignore navigation events dispatched to disconnected inputs. Previously, dispatching events to a removed input would throw an
IllegalStateException. I1a8bc b/515890298 - Prevent symbol duplication with older JetBrains fork versions when upgrading to Compose Multiplatform 1.11.0. I4cc4d
There are no release notes for this artifact.
Bug Fixes
- This library now uses JSpecify nullness annotations, which are type-use. Kotlin developers should use the following compiler arguments to enforce correct usage: -Xjspecify-annotations=strict, -Xtype-enhancement-improvements-strict-mode Ideef8 b/326456246
- Merged public and experimental API files for n- thru t-paths I103c7 b/278769092
External Contribution
- Merge palette-ktx into the palette library. All Kotlin extensions are now part of the main palette artifact. palette-ktx is now an empty artifact for compatibility. I3f1df
There are no release notes for this artifact.
API Changes
- Make
AnnotationViewpublic I8219f - Make
EditablePdfDocumentand annotations classes public. I5b962 - Introduced new pdf-core submodule Iea331
- Relocated core pdf apis to new pdf-core artifact to decouple document models from the view implementation. I26e1f
- Expose
OcrProviderAPIs to support image-based text recognition I5271b - Removed the deprecated parameterless
onLoadDocumentSuccess()method fromPdfViewerFragmentand the deprecatedisLinearizedproperty fromPdfDocument. I6b7ab - Autofill support for form filling is enabled.
Bug Fixes
- Fixed an issue where horizontal scrolling was unreliable at page edges because scroll direction was not accounted for when managing touch event interception. I6bda5 b/505645009
- Fixed an issue to ensure the fast scroller is always displayed when accessibility is enabled. Idaf5e b/513082550
API Changes
- Lowered the
minSdkof the androidx.photopicker:photopicker and androidx.photopicker:photopicker-compose libraries to 23, while the APIs still require to be called starting from 34. I94e42 b/524083018 - Updating Embedded PhotoPicker Compose APIs (removing AbstractEmbeddedPhotoPickerState, renaming and change visibility of some fields from EmbeddedPhotoPickerState) Ie32c9 b/449786033
Bug Fixes
- Updated Compose compileSdk to API 37. This means that a minimum AGP version of 9.2.0 is required when using Compose. Ic748a b/413674743
API Changes
- Exposed
RemoteDensityBehaviorand density-behavior-aware constructors inRemoteCreationDisplayInfoas public APIs. Iafca2 b/524921038 - Exposed
densityBehaviorinRemoteCreationDisplayInfoandRemoteComposeCreationState. Iae938 b/524921038 - Made
RemoteComposeCreationComposeFlagspublic. I1f899 b/467532762
Bug Fixes
- Added lint check to warn about usage of standard Compose
CompositionLocalsin @RemoteComposable. Ic12ba - Remove requirement for
compileSdk 37If78b4 - Removed obsolete
rememberRemoteStringListdocumentation. I99722 - Fixed font weight adjustment rendering when adjustment is undefined. I16704 b/522050705
- Aligned
BorderModifierto Compose behavior to draw inside the component bounds. Iae36c - Fixed
RemoteComposeWriterto serializeDOC_PROFILESin the constructor. I3bbea - Fixed
RemoteModifier.backgroundnative support for dynamic colors. If4f04 b/499049643
Features - Added typefaceResolver parameter to RemoteDocumentPlayer. Ie7cda b/524621320 - Added custom component support for the Compose player. Ic0559 - Optimized select operations where both alternatives are the same. I55b9e b/390355362
Major features of 3.0.0:
Room 3.0 (package androidx.room3) is a major version update of Room 2.x package (androidx.room) that focuses on Kotlin Multiplatform (KMP).
The core annotation APIs are kept the same along with the main components:
- An abstract class that extends
androidx.room3.RoomDatabaseand is annotated with@Databaseis the entry point for Room's annotation processor. - The database declaration has one or more data classes describing the database schema and are annotated with
@Entity. - Database operations are defined in
@Daodeclarations that contains query functions whose SQL statements are defined via the@Queryannotation. - At runtime, the database implementation can be obtained via a
RoomDatabase.Builderwhich is also used to configure the database.
Most of the documentation in the Save data in a local database using Room guide is still relevant to Room 3.0.
The major breaking differences between Room 2.x are as follows:
- New package,
androidx.room3. - SupportSQLite APIs are no longer supported, unless you are using the
androidx.room3:room3-sqlite-wrapper. - All database operations are now Coroutine APIs based.
- Kotlin code generation only.
- Kotlin Symbol Processing (KSP) is required.
Along with breaking changes, Room 3.0 brings in new functionality compared to 2.x:
- JS and WasmJS Support
- Custom DAO Return Types
- FTS5 support via
@Fts5annotation - Kotlin default parameter value support
PrimaryKey.algorihtmproperty to specify the primary key generating algorithm- Ability to create tables 'WITHOUT ROWID'
- Composite relationship column with
@Relation
New Package
To prevent compatibility issues with existing Room 2.x implementations and for libraries with transitive dependencies to Room (for example, WorkManager), Room 3.0 resides in a new package, which means it also has a new maven group and artifact ids. For example, androidx.room:room-runtime has become androidx.room3:room3-runtime and classes such as androidx.room.RoomDatabase will now be located at androidx.room3.RoomDatabase.
No SupportSQLite APIs
Room 3.0 is fully backed by the SQLiteDriver APIs and no longer references SupportSQLite types such as SupportSQLiteDatabase or Android types such as Cursor. This is the most significant change between Room 3.0 and 2.x since the RoomDatabase APIs that mirrored SupportSQLiteDatabase along with the API to get a SupportSQLiteOpenHelper have been removed. A SQLiteDriver is now required to build a RoomDatabase.
For example, APIs for direct database operations are replaced by driver equivalents:
// Room 2.x
roomDatabase.runInTransaction { ... }
// Room 3.x
roomDatabase.withWriteTransaction { ... }
// Room 2.x
roomDatabase.query("SELECT * FROM Song").use { cursor -> ... }
// Room 3.x
roomDatabase.useReaderConnection { connection ->
connection.usePrepared("SELECT * FROM Song") { stmt -> ... }
}
Callback APIs that had as argument a SupportSQLiteDatabase have also been replaced by their equivalent API that has a SQLiteConnection as argument. These are migrations callback functions such as Migration.onMigrate() and AutoMigrationSpec.onPostMigrate() along with database callbacks such as RoomDatabase.Callback.onCreate(), RoomDatabase.Callback.onOpen(), etc.
If Room was being used in a KMP project, then migrating to 3.0 is simpler as it mostly involves updating import references, otherwise the same migration strategy from Room in Android-only to KMP applies, see the Room KMP Migration Guide.
SupportSQLite Wrapper
Room 3.x preserves the SupportSQLite wrapper created in 2.x to ease migrations and is now located in a new artifact androidx.room3:room3-sqlite-wrapper. The compatibility API allows you to convert a RoomDatabase into a SupportSQLiteDatabase. Invocations of roomDatabase.openHelper.writableDatabase can be replaced by roomDatabase.getSupportWrapper().
Kotlin and Coroutines First
To better evolve the library, Room 3.0 only generates Kotlin code and is only a Kotlin Symbol Processor (KSP). Compared to Room 2.x there is no Java code generation and configuration of annotation processor via KAPT or JavaAP is no longer possible in Room 3.0. Note that KSP is able to process Java sources and the Room compiler will generate code for database, entities or DAOs whose source declarations are in Java. It is recommended to have a multi-module project where Room usage is concentrated and the Kotlin Gradle Plugin and KSP can be applied without affecting the rest of the codebase.
Room 3.0 also requires the use of Coroutines, and more specifically DAO functions have to be suspending unless they are returning a reactive type, such as a Flow or a custom DAO return type. Room APIs to perform database operations are also suspend functions, such as RoomDatabase.useReaderConnection and RoomDatabase.useWriterConnection.
As opposed to Room 2.x it is no longer possible to configure a RoomDatabase with an Executor, instead a CoroutineContext along with a dispatcher can be provided via the database's builder.
InvalidationTracker APIs in Room 3.0 are Flow based, InvalidationTracker.Observer is removed along with its relevant APIs addObserver and removeObserver. The mechanism to react to database operation is through Coroutine Flows that can be created via the createFlow() API in the InvalidationTracker.
Example usage:
fun getArtistTours(from: Date, to: Date): Flow<Map<Artist, TourState>> {
return db.invalidationTracker.createFlow("Artist").map { _ ->
val artists = artistsDao.getAllArtists()
val tours = tourService.fetchStates(artists.map { it.id })
associateTours(artists, tours, from, to)
}
}
Web Support
The Room 3.0 release adds JavaScript and WasmJs as KMP targets. Combined with the release of the SQLiteDriver interfaces (androidx.sqlite:sqlite) that also target JavaScript and WasmJs and a new driver WebWorkerSQLiteDriver located in the new artifact androidx.sqlite:sqlite-web, it is possible to use Room in common code that targets all major KMP platforms.
Due to the asynchronous nature of the web platforms, Room APIs that took SQLiteStatement as argument are now suspend functions. Example of these functions are Migration.onMigrate(), RoomDatabase.Callback.onCreate(), PooledConnection.usePrepared() and others. In the driver APIs the asynchronous APIs are common on all platforms and the synchronous are common for non-web targets. Therefore a project that does not target web can continue to use the synchronous APIs (SQLiteDriver.open(), SQLiteConnection.prepare() and SQLiteStatement.step()) in common code. Meanwhile a project that only targets web must use the asynchronous APIs (SQLiteDriver.openAsync(), SQLiteConnection.prepareAsync() and SQLiteStatement.stepAsync()).
For convenience the androidx.sqlite package also added suspend extension functions with the synchronous names of the mentioned APIs (with the addition of SQLiteConnection.executeSQL), these APIs are recommended when the project targets both web and non-web platforms since the APIs are expect / actual declarations that will call the right variant based on the platforms. These are the APIs Room's runtime use and enable driver usage in common code for all supported platforms.
Example usage:
import androidx.sqlite.executeSQL
import androidx.sqlite.step
roomDatabase.useWriterConnection { connection ->
val deletedSongs = connection.usePrepared(
"SELECT count(*) FROM Song"
) { stmt ->
stmt.step()
stmt.getLong(0)
}
connection.executeSQL("DELETE FROM Song")
deletedSongs
}
The WebWorkerSQLiteDriver is an implementation of a SQLiteDriver that communicates with a Web Worker for performing database operation off the main thread and enables storing the database in the Origin Private File System (OPFS). To instantiate the driver a worker that implements a simple communication protocol is required, the protocol is described in the WebWorkerSQLiteDriver KDoc.
Currently the WebWorkerSQLiteDriver does not ship with a default worker that implements the communication protocol, but as an example, the androidx codebase contains a worker implementation that can be used in your project. It uses SQLite's WASM and stores the database in OPFS. The example worker is published as a local NPM package and thanks to Kotlin's support for NPM dependencies, a small KMP module can be created to serve the worker.
See the following GitHub project demonstrating the usage of a local web worker for Room.
Once a worker is set up in the project, then configuring Room for the Web is similar to other platforms:
fun createDatabase(): MusicDatabase {
return Room.databaseBuilder<MusicDatabase>("music.db")
.setDriver(WebWorkerSQLiteDriver(createWorker()))
.build()
}
fun createWorker() =
Worker(js("""new URL("sqlite-web-worker/worker.js", import.meta.url)"""))
A future version of the Web driver might contain a default worker published in NPM, making the web setup simpler.
Custom DAO Return Types
Various DAO return type integrations such as those for RxJava and Paging have been transformed to use a new API in Room 3.0 called DAO return type converters. A DAO return type converter function (@DaoReturnTypeConverter) enables transforming the result of a DAO function into a custom type defined by the annotated function. These functions enable participating in Room's generated code that transforms query results into data objects. Classes that contain DAO return type converters have to be registered via the @DaoReturnTypeConverters annotations in the @Database or @Dao declarations.
For example, to have a DAO query return a PagingSource, the converter class located in androidx.room3:room3-paging must now be registered:
@Dao
@DaoReturnTypeConverters(PagingSourceDaoReturnTypeConverter::class)
interface MusicDao {
@Query("SELECT * FROM Song)
fun getSongsPaginated(): PagingSource<Int, Song>
}
Existing integrations have been moved to DAO return type converters:
| Return Type | Converter class | Artifact |
|---|---|---|
| PagingSource | PagingSourceDaoReturnTypeConverter | androidx.room3:room3-paging |
| Observable, Flowable, Completable, Single, Maybe | RxDaoReturnTypeConverters | androidx.room3:room3-rxjava3 |
| ListenableFuture | GuavaDaoReturnTypeConverter | androidx.room3:room3-guava |
| LiveData | LiveDataDaoReturnTypeConverter | androidx.room3:room3-livedata |
Like column type converters, DAO return type converters can be defined by the application. For example, an application could declare a @DaoReturnTypeConverter for the web type kotlin.js.Promise.
object PromiseDaoReturnTypeConverter {
@DaoReturnTypeConverter([OperationType.READ, OperationType.WRITE])
fun <T> convert(
db: RoomDatabase,
executeAndConvert: suspend () -> T
): Promise<T> {
return db.getCoroutineScope().promise { executeAndConvert() }
}
}
The above converter then allows DAO query functions to return Promise:
@Dao
@DaoReturnTypeConverters(PromiseDaoReturnTypeConverter::class)
interface MusicDao {
@Query("SELECT * FROM Song")
fun getAllSongs(): Promise<List<Song>>
}
A @DaoReturnTypeConverter function has a few requirements in the amount of parameter it must have and its types. The possible parameters are:
db: RoomDatabase: (Optional) Provides access to theRoomDatabaseinstance, which can be useful for performing additional database operations or accessing the coroutine scope.tableNames: Array<String>: (Optional) Contains the accessed tables of the query, useful for supporting observable / reactive types when combined with Room'sInvalidationTracker.createFlow()API.rawQuery: RoomRawQuery: (Optional) Contains at runtime an instance of the query, enabling transformations such as theLIMIT/OFFSETstrategy implemented by thePagingSourceDaoReturnTypeConverter.executeAndConvert: suspend () -> T: (Required) The Room generated function that will execute the query and parse its result into data objects.
For more information about the requirements for creating a DAO return type converter, see the KDoc on the @DaoReturnTypeConverter API.
Important changes since 2.6.0:
- Add js and wasmJs targets to
androidx.sqlite:sqlitealong with asynchronous version of the driver APIs:SQLiteDriver.open(),SQLiteConnection.prepare()andSQLiteStatement.step()for the web targets. - Existing projects that don't target web can continue using the synchronous APIs in common code, but once a project targets web then only the asynchronous APIs are available. For convenience a new artifact
andriodx.sqlite:sqlite-asyncincludes top-level suspend functions that use the synchronous naming scheme (along withexecuteSQL) and are expect / actual declarations that will invoke the right variant based on the platform. It is recommended to use these APIs for common code targeting both web and non-web targets. - This release also includes a new artifact
androidx.sqlite:sqlite-webwhich containsWebWorkerSQLiteDriver, aSQLiteDriverimplementation for the web that communicates with a Web Worker to perform database operation via a simple messaging protocol. The protocol is documented in theWebWorkerSQLiteDriverand even though there is no default worker implementation with the artifact, one can be provided via the constructor. For a more concrete example on how this new artifact can be used, check out the Room 3.0 release notes.
Important changes since 2.3.0:
The API surface of UiAutomator has been overhauled to provide:
- A dedicated
uiAutomatortest scope for cleaner and more expressive test code. - Methods like
onElement,onElements, andonElementOrNullfor finding UI elements with clear predicates. - Built-in waiting mechanism for conditional elements
onElement*(timeoutMs: Long = 10000) - Explicit app state management such as
waitForStableandwaitForAppToBeVisible. - Direct interaction with accessibility window nodes for multi-window testing scenarios.
- Built-in screenshot capabilities and a
ResultsReporterfor visual testing and debugging.
To get started with the new APIs, see the UiAutomator 2.4+ guide.
API Changes
Added the
TransformingLazyColumnFirstLayoutItemProviderinterface in Foundation to enable customization of content that shifts direction during content updates, accompanied by out-of-the-boxrememberTransformingLazyColumnFirstLayoutItemProviderandrememberTransformingLazyColumnFirstVisibleItemProviderimplementations in Material3. I54814 b/503353428Renamed the fallback parameter from
currenttocenterIteminTransformingLazyColumnFirstLayoutItemProvider. AddedTransformingLazyColumnStateextensionsfirstVisibleItemLayoutItemInfoandlayoutItemInfoOf, and updatedrememberTransformingLazyColumnFirstLayoutItemProviderto use a clean, parameter-based lambda. I9a8d9 b/503353428Add overloads for multi-slot Material3 Button and Card content, for use with one-handed gestures. I74ccb b/515718015 b/490343658
Add accessibility support to one-handed gestures. I0054d b/519085906
Rename
OneHandedGestureDefaults.scrollToNextItem()toOneHandedGestureDefaults.scrollDownToNextItemand addwrapAroundparameter toOneHandedGestureDefaultsscroll functions I940ce b/509639667Add non-composable
Modifier.oneHandedGesture()if developer wants to provide the key manually. I191e1 b/504712626Rename
offsetOfAPI inRevealStatetopositionOf. I2675f b/522387997Introduced
actionContentSpacingparameter toSwipeToReveal, allowing developers to customize the distance between action slots and the content. I2abaf b/507073912
Bug Fixes
- Fixed an issue in
ScreenScaffoldwhere recompositions could cause un-rememberedScrollInfoProviderto reset scroll tracking state. I98f6d b/524620765 TransformingLazyColumnscrollbar color follows gesture indicator background color during indicator animation I353fb b/524915104- Changed
OneHandedGestureIndicatordefaultgestureIndicatorTinttoLocalContentColorI1abd3 b/524228063 - Parameterize the content description of
DatePicker's day and year pickers to support localization. I5dcd9 b/430563857 - Introduce adaptive display frequencies to
GestureIndicatorsbased on whether an indicator renders inside or outside its host UI component. Ic618f b/515071642 - Fix concurrency issue when triggering one-handed gestures I7b95f b/512086558
Vulnerability & Security Fixes
- Enforced a
2048pxdimension limit and20MBraw size maximum on images to prevent memory exhaustion. - Enforced layout depth checks by fixing a bug that allowed deep layouts to skip depth enforcement during fingerprint optimizations.
- Prevented an array bounds exception/crash caused by unbounded gap parameters in
DashedArcLine. - Replaced uncaught
IllegalArgumentExceptionswith safer error logging and node invalidation in expression pipeline. - Fixed an uncaught
NullPointerExceptionwhen processing malformed image URIs.
Bug Fixes
- An updated release depending on androidx.compose.remote at the same commit to avoid binary incompatibility
Vulnerability & Security Fixes
- Fixed a potential
IllegalStateExceptionrace condition inTilesConnectionBinderthat occurred during service connection callbacks called from unexpected threads.
API Changes
- Added an
HttpCacheAPI, accessible viaProfile#getHttpCache, providing the ability to query and manage the HTTP cache quota for a profile. This can benefit the performance and availability of apps which rely heavily on web-served static content, or alternatively reduce cache directory usage where HTTP caching is not needed. This feature requiresWebViewversion M151 or higher. I40a7f b/501449506 - Removed incorrect
@RequiresFeatureannotations onScriptHandlerandUserAgentMetadata#getFormFactors. Ib9550
Lint Checks
- Introduced a lint warning for unhandled
onRenderProcessGonecallback. This callback gives developers an opportunity to gracefully recover from a render process shutting down rather than crashing their app. A warning will be linted if aWebViewClienthas been used but it has not overridden this callback. Ia4e41