
Posted by Amanda Alexander, Product Supervisor, Android
Android Jetpack is a key pillar of Trendy Android Improvement. It’s a suite of over 100 libraries, instruments and steerage to assist builders comply with finest practices, scale back boilerplate code, and write code that works constantly throughout Android variations and gadgets so that you could concentrate on constructing distinctive options to your app. The vast majority of apps on Google Play depend on Jetpack, the truth is over 90% of the highest 1000 apps use Jetpack.
Beneath we’ll cowl highlights of current updates in three main areas of Jetpack:
- Structure Libraries and Steerage
- Efficiency Optimization of Functions
- Consumer Interface Libraries and Steerage
After which conclude with some extra key updates.
1. Structure Libraries and Steerage
App structure libraries and elements be certain that apps are sturdy, testable, and maintainable.
Information Persistence
Most functions must persist native state – whether or not or not it’s caching outcomes, managing native lists of person enter knowledge, or powering knowledge returned within the UI. Room is the beneficial knowledge persistence layer which supplies an abstraction layer over SQLite, permitting for elevated usability and security over the platform.
In Room, we’ve got added many brand-new options, such because the Upsert operation, which makes an attempt to insert an entity when there isn’t any uniqueness battle or replace the entity if there’s a battle, and help for utilizing Kotlin worth courses for KSP. These new options can be found in Room 2.6-alpha with all library sources written in Kotlin and helps each the Java programming language and Kotlin code era.
Managing duties with WorkManager
The WorkManager library makes it straightforward to schedule deferrable, asynchronous duties that should be run reliably as an illustration importing backups or analytics. These APIs allow you to create a activity and hand it off to WorkManager to run when the work constraints are met.
Now, WorkManager permits you to replace a WorkRequest after you will have already enqueued it. That is typically needed in bigger apps that incessantly change constraints or must replace their staff on the fly. As of WorkManager 2.8.0, the updateWork() API is the technique of doing this with out having to undergo the method of manually canceling and enqueuing a brand new WorkRequest. This vastly simplifies the event course of.
DataStore
The DataStore library is a sturdy knowledge storage resolution that addresses points with SharedPreferences and supplies a contemporary coroutines primarily based API.
In DataStore 1.1 alpha we added a extensively requested function: multi-process help which lets you entry the DataStore from a number of processes whereas offering knowledge consistency ensures between them. Further options embrace a brand new storage interface that permits the underlying storage mechanism for Datastore to be switched out (we’ve got supplied implementations for java.io and okio), and we’ve got additionally added help for Kotlin Multiplatform.
Lifecycle administration
Lifecycle-aware elements carry out actions in response to a change within the lifecycle standing of one other part, similar to actions and fragments. These elements enable you to produce better-organized, and infrequently lighter-weight code, that’s simpler to take care of.
We launched a secure model of Lifecycle 2.6.0 that features extra Compose integration. We added a brand new extension technique on Movement, collectAsStateWithLifecycle(), that collects from flows and represents its newest worth as Compose State in a lifecycle-aware method. Moreover, numerous courses are transformed to Kotlin and nonetheless retain their binary compatibility with earlier variations.
Predictive Again Gesture
![]() |
In Android 13, we launched a predictive again gesture for Android gadgets similar to telephones, massive screens, and foldables. It’s a part of a multi-year launch; when absolutely applied, this function will let customers preview the vacation spot or different results of a again gesture earlier than absolutely finishing it, permitting them to resolve whether or not to proceed or keep within the present view.
The Exercise APIs for Predictive Again for Android are secure and we’ve got up to date the finest practices for utilizing the supported system again callbacks; BackHandler (for Compose), OnBackPressedCallback, or OnBackInvokedCallback. We’re excited to see Google apps undertake Predictive Again together with PlayStore, Calendar, Information, and TV!
Within the Exercise 1.8 alpha releases, The OnBackPressedCallback class now comprises new Predictive Again progress callbacks for dealing with the again gesture beginning, progress all through the gesture, and the again gesture being canceled along with the earlier handleOnBackPressed() callback for when the again gesture is dedicated. We additionally added ComponentActivity.setUpEdgeToEdge() to simply arrange the edge-to-edge show in a backward-compatible method.
Exercise updates for extra constant Picture Picker expertise
The Android picture picker is a browsable interface that presents the person with their media library. In Exercise 1.7.0, the Picture Picker exercise contracts have been up to date to include a further fallback that enables OEMs and system apps, similar to Google Play providers, to offer a constant Picture Picker expertise on a wider vary of Android gadgets and API ranges by implementing the fallback motion. Learn extra within the Picture Picker In every single place weblog.
Incremental Information Fetching
The Paging library permits you to load and show small chunks of knowledge to enhance community and system useful resource consumption. App knowledge will be loaded progressively and gracefully inside RecyclerViews or Compose lazy lists.
In Paging Compose 1.0.0-alpha19, there’s help for all lazy layouts together with customized layouts supplied by the Put on and TV libraries. To help extra lazy layouts, Paging Compose now supplies barely decrease degree extension strategies on LazyPagingItems in itemKey and itemContentType. These APIs concentrate on serving to you implement the important thing and contentType parameters to the usual gadgets APIs that exist already for LazyColumn, LazyVerticalGrid in addition to their equivalents in APIs like HorizontalPager. Whereas these modifications do make the LazyColumn and LazyRow examples just a few traces longer, it supplies consistency throughout all lazy layouts.
2. Efficiency Optimization of Functions
Utilizing efficiency libraries permits you to construct performant apps and determine optimizations to take care of excessive efficiency, leading to higher end-user experiences.
Bettering Begin-up Occasions
Baseline Profiles mean you can partially compile your app at set up time to enhance runtime and launch efficiency, and are getting large enhancements in new tooling and libraries:
Jetpack supplies a brand new Baseline Profile Gradle Plugin in alpha, which helps AGP 8.0+, and will be simply added to your challenge in Studio Hedgehog (now in canary). The plugin enables you to automate the duty of operating era duties, and pulling profiles from the machine and integrating them into your construct both periodically, or as a part of your launch course of.
The plugin additionally permits you to simply automate the brand new Dex Structure Optimization function in AGP 8.1, which helps you to outline BaselineProfileRule checks that acquire courses used throughout startup, and transfer them to the first dex file in a multidex app to extend locality. In a big app, this could enhance chilly startup time by 30% on prime of Baseline Profiles!
Macrobenchmark 1.2 has shipped a number of new options in alpha, similar to Energy metrics and Customized hint metrics, era of Baseline Profiles with out root on Android 13, and recompilation with out clearing app knowledge on Android 14.
You may learn every little thing in depth within the weblog “What’s new in Android Efficiency“.
3. Consumer Interface Libraries and Steerage
A number of modifications have been made to our UI libraries to offer higher help for large-screen compatibility, foldables, and emojis.
Jetpack Compose
Jetpack Compose, Android’s trendy toolkit for constructing native UI, just lately had its Might 2023 launch which incorporates new options for textual content and layouts, continued efficiency enhancements, enhanced tooling help, elevated help for big screens, and up to date steerage. You may learn extra within the What’s New in Jetpack Compose I/O weblog to be taught extra.
Look
The Look library, now in 1.0-beta, enables you to develop app widgets optimized for Android telephone, pill, and foldable homescreens utilizing Jetpack Compose. The library offers you the newest Android widget enhancements out of the field, utilizing Kotlin and Compose.
Compose for TV
With the alpha launch of the TV library, now you can construct experiences for Android TV utilizing elements optimized for the lounge expertise. Compose for TV unlocks all the advantages of Jetpack Compose to your TV apps, permitting you to construct apps with much less code, simpler upkeep and a contemporary Materials 3 look straight out of the field. See the Compose for TV weblog for particulars.
Materials 3 for Compose
Materials Design 3 is the subsequent evolution of Materials Design, enabling you to construct expressive, spirited and private apps. It’s the beneficial design system for Android apps and the 1.1 secure launch brings thrilling new options similar to backside sheets, date and time pickers, search bars, tooltips, and added extra movement and interplay help. Learn extra within the launch weblog.
Understanding Window State
The brand new WindowManager library helps builders adapt their apps to help multi-window environments and new machine type components by offering a standard API floor with help again to API degree 14.
In 1.1.0-beta01, new options and capabilities have been added to exercise embedding and window format that lets you optimize your multi-activity apps for big screens. With the 1.1 launch of Jetpack WindowManager, exercise embedding APIs are now not experimental and are beneficial for multi-activity functions to offer improved massive display layouts. Take a look at the What’s new in WindowManager 1.1.0-beta01 weblog for particulars and migration steps.
Different key updates
Kotlin Multiplatform
We proceed to experiment with utilizing Kotlin Multiplatform to share enterprise logic between Android and iOS. The Collections 1.3.0-alpha03 and DataStore 1.1.0-alpha02 have been up to date so now you can use these libraries in KMM tasks. If you’re utilizing Kotlin Multiplatform in your app, we want your suggestions!
This was a take a look at all of the modifications in Jetpack over the previous few months that will help you construct apps extra productively. For extra particulars on every Jetpack library, try the AndroidX launch notes, rapidly discover related libraries with the API picker and watch the Google I/O talks for added highlights.
Java is a trademark or registered trademark of Oracle and/or its associates.