What’s New in Jetpack Compose

0
1
What’s New in Jetpack Compose



What’s New in Jetpack Compose

Posted by Nick Butcher – Product Supervisor

At Google I/O 2025, we introduced a number of options, efficiency, stability, libraries, and instruments updates for Jetpack Compose, our really useful Android UI toolkit. With Compose you may construct glorious apps that work throughout units. Compose has matured loads because it was first introduced (at Google I/O 2019!) and we’re now seeing 60% of the highest 1,000 apps within the Play Retailer equivalent to MAX and Google Drive use and like it.

New Options

Since I/O final 12 months, Compose Invoice of Supplies (BOM) model 2025.05.01 provides new options equivalent to:

    • Autofill assist that lets customers routinely insert beforehand entered private info into textual content fields.
    • Auto-sizing textual content to easily adapt textual content dimension to a dad or mum container dimension.
    • Visibility monitoring for if you want high-performance info on a composable’s place in its root container, display, or window.
    • Animate bounds modifier for lovely computerized animations of a Composable’s place and dimension inside a LookaheadScope.
    • Accessibility checks in assessments that allow you to construct a extra accessible app UI via automated a11y testing.

LookaheadScope {
    Field(
        Modifier
            .animateBounds(this@LookaheadScope)
            .width(if(inRow) 100.dp else 150.dp)
            .background(..)
            .border(..)
    )
}

moving image of animate bounds modifier in action

For extra particulars on these options, learn What’s new within the Jetpack Compose April ’25 launch and take a look at these talks from Google I/O:

In case you’re seeking to check out new Compose performance, the alpha BOM gives new options that we’re engaged on together with:

    • Pausable Composition (see beneath)
    • Updates to LazyLayout prefetch
    • Context Menus
    • New modifiers: onFirstVisible, onVisbilityChanged, contentType
    • New Lint checks for steadily altering values and components that needs to be remembered in composition

Please check out the alpha options and present suggestions to assist form the way forward for Compose.

Materials Expressive

At Google I/O, we unveiled Materials Expressive, Materials Design’s newest evolution that helps you make your merchandise much more partaking and simpler to make use of. It is a complete addition of recent parts, types, movement and customization choices that enable you to construct lovely wealthy UIs. The Material3 library within the newest alpha BOM accommodates most of the new expressive parts so that you can check out.

moving image of material expressive design example

Study extra to begin constructing with Materials Expressive.

Adaptive layouts library

Creating adaptive apps throughout kind elements together with telephones, foldables, tablets, desktop, automobiles and Android XR is now simpler with the most recent enhancements to the Compose adaptive layouts library. The secure 1.1 launch provides assist for predictive again gestures for smoother transitions and pane enlargement for extra versatile two pane layouts on bigger screens. Moreover, the 1.2 (alpha) launch provides extra flexibility for the way panes are displayed, including methods for reflowing and levitating.

moving image of compose adaptive layouts updates in the Google Play app

Compose Adaptive Layouts Updates within the Google Play app

Study extra about constructing adaptive android apps with Compose.

Efficiency

With every launch of Jetpack Compose, we proceed to prioritize efficiency enhancements. The most recent secure launch consists of vital rewrites and enhancements to a number of sub-systems together with semantics, focus and textual content optimizations. Better of all these can be found to you just by upgrading your Compose dependency; no code modifications required.

bar chart of internal benchmarks for performance run on a Pixel 3a device from January to May 2023 measured by jank rate

Inside benchmark, run on a Pixel 3a

We proceed to work on additional efficiency enhancements, notable modifications within the newest alpha BOM embrace:

    • Pausable Composition permits compositions to be paused, and their work break up up over a number of frames.
    • Background textual content prefetch allows textual content format caches to be pre-warmed on a background thread, enabling quicker textual content format.
    • LazyLayout prefetch enhancements enabling lazy layouts to be smarter about how a lot content material to prefetch, profiting from pausable composition.

Collectively these enhancements eradicate practically all jank in an inside benchmark.

Stability

We have heard from you that upgrading your Compose dependency may be difficult, encountering bugs or behaviour modifications that forestall you from staying on the most recent model. We have invested considerably in enhancing the steadiness of Compose, working carefully with the numerous Google app groups constructing with Compose to detect and forestall points earlier than they even make it to a launch.

Google apps develop towards and launch with snapshot builds of Compose; as such, Compose is examined towards the lots of of hundreds of Google app assessments and any Compose points are instantly actioned by our crew. Now we have just lately invested in rising the cadence of updating these snapshots and now replace them every day from Compose tip-of-tree, which implies we’re receiving suggestions quicker, and are in a position to resolve points lengthy earlier than they attain a public launch of the library.

Jetpack Compose additionally depends on @Experimental annotations to mark APIs which are topic to vary. We heard your suggestions that some APIs have remained experimental for a very long time, decreasing your confidence within the stability of Compose. Now we have invested in stabilizing experimental APIs to offer you a extra stable API floor, and diminished the variety of experimental APIs by 32% within the final 12 months.

Now we have additionally heard that it may be exhausting to debug Compose crashes when your personal code doesn’t seem within the stack hint. Within the newest alpha BOM, we’ve got added a brand new opt-in function to offer extra diagnostic info. Observe that this doesn’t presently work with minified builds and comes at a efficiency value, so we suggest solely utilizing this function in debug builds.

class App : Utility() {
   override enjoyable onCreate() {
        // Allow just for debug taste to keep away from perf affect in launch
        Composer.setDiagnosticStackTraceEnabled(BuildConfig.DEBUG)
   }
}

Libraries

We all know that to construct nice apps, you want Compose integration within the libraries that work together together with your app’s UI.

A core library that powers any Compose app is Navigation. You informed us that you simply typically encountered limitations when managing state hoisting and instantly manipulating the again stack with the present Compose Navigation answer. We went again to the drawing-board and utterly reimagined how a navigation library ought to combine with the Compose psychological mannequin. We’re excited to introduce Navigation 3, a brand new artifact designed to empower you with better management and simplify complicated navigation flows.

We’re additionally investing in Compose assist for CameraX and Media3, making it simpler to combine digital camera seize and video playback into your UI with Compose idiomatic parts.

@Composable
non-public enjoyable VideoPlayer(
    participant: Participant?, // from media3
    modifier: Modifier = Modifier
) {
    Field(modifier) {
        PlayerSurface(participant) // from media3-ui-compose
        participant?.let {
            // customized play-pause button UI
            val playPauseButtonState = rememberPlayPauseButtonState(it) // from media3-ui-compose
            MyPlayPauseButton(playPauseButtonState, Modifier.align(BottomEnd).padding(16.dp))
        }
    }
}

To be taught extra, see the media3 Compose documentation and the CameraX samples.

Instruments

We proceed to enhance the Android Studio instruments for creating Compose UIs. The newest Narwhal canary consists of:

    • Resizable Previews immediately present you ways your Compose UI adapts to totally different window sizes
    • Preview navigation enhancements utilizing clickable names and parts
    • Studio Labs 🧪: Compose preview technology with Gemini rapidly generate a preview
    • Studio Labs 🧪: Rework UI with Gemini change your UI with pure language, instantly from preview.
    • Studio Labs 🧪: Picture attachment in Gemini generate Compose code from photographs.

For extra info learn What’s new in Android growth instruments.

moving image of resizable preview in Jetpack Compose

Resizable Preview

New Compose Lint checks

The Compose alpha BOM introduces two new annotations and related lint checks that will help you to put in writing appropriate and performant Compose code. The @FrequentlyChangingValue annotation and FrequentlyChangedStateReadInComposition lint examine warns in conditions the place operate calls or property reads in composition would possibly trigger frequent recompositions. For instance, frequent recompositions would possibly occur when studying scroll place values or animating values. The @RememberInComposition annotation and RememberInCompositionDetector lint examine warns in conditions the place constructors, features, and property getters are known as instantly inside composition (e.g. the TextFieldState constructor) with out being remembered.

Completely satisfied Composing

We proceed to put money into offering the options, efficiency, stability, libraries and instruments that it’s worthwhile to construct glorious apps. We worth your enter so please share suggestions on our newest updates or what you’d prefer to see subsequent.

Discover this announcement and all Google I/O 2025 updates on io.google beginning Could 22.

LEAVE A REPLY

Please enter your comment!
Please enter your name here