Skip to content

2022-01-26

Choose a tag to compare

@github-actions github-actions released this 26 Jan 18:45
· 229 commits to main since this release

Activity: v1.5.0-alpha01

January 26, 2022

androidx.activity:activity:1.5.0-alpha01, androidx.activity:activity-compose:1.5.0-alpha01, and androidx.activity:activity-ktx:1.5.0-alpha01 are released. Version 1.5.0-alpha01 contains these commits.

New Features

  • ComponentActivity now integrates with ViewModel CreationExtras, introduced as part of Lifecycle 2.5.0-alpha01. (Ie7e00, b/207012584)
  • Added ComponentDialog, a subclass of Dialog that includes an OnBackPressedDispatcher that will be called when the system back button is pressed when the dialog is visible. Importantly, this subclass also sets the ViewTreeOnBackPressedDispatcherOwner, allowing views a generic way to retrieve the correct dispatcher whether it exists in a ComponentActivity or a ComponentDialog. (I8a1bc)
  • ComponentActivity now implements the new OnNewIntentProvider interface to allow any component to receive these events. (If1f8b)
  • ComponentActivity now implements the new OnConfigurationChangedProvider interface to allow any component to receive these events. (If623b)
  • ComponentActivity now implements the new OnTrimMemoryProvider interface to allow any component to receive these events. (Ia9295)

API Changes

  • The no parameter constructor for ActivityResultContracts.CreateDocument has been deprecated and replaced with a new constructor that takes a concrete mime type (e.g., "image/png") as is required by Intent.ACTION_CREATE_DOCUMENT. (I2bec6)
  • The OnBackPressedDispatcherOwner associated with a View can now be retrieved via the ViewTreeOnBackPressedDispatcherOwner, rather than relying on casting the Context. (I74685)

Bug Fixes

  • Fixed a crash when accessing a ViewModel for the very first time from a registerForActivityResult() callback or the callbacks to a LifecycleObserver added as part of init of a ComponentActivity. (Ife83f)

Benchmark: v1.1.0-beta02

January 26, 2022

androidx.benchmark:benchmark-*:1.1.0-beta02 is released. Version 1.1.0-beta02 contains these commits.

Bug Fixes

  • Microbenchmark Stack Sampling / Method Tracing Profile results are now linked in Studio output, similar to other profiling outputs, and do not suppress the allocation metric. (Idcb65, b/214440748, b/214253245)
  • BaselineProfileRule now prints the adb pull command in logcat and Studio output for pulling generated BaselineProfile text file. (f08811)

Camera-Camera2, Camera-Core, Camera-Lifecycle, & Camera-Video: v1.1.0-beta01

January 26, 2022

androidx.camera:camera-*:1.1.0-beta01 is released. Version 1.1.0-beta01 contains these commits.

New Features

  • From 1.1.0-beta01, all CameraX libraries will align the same version number. This will help developers track versions much easier and reduce the complexity of large version compatibility matrix.

API Changes

  • Added Camera2CameraControl.clearCaptureRequestOptions for clearing the existing capture request options. (Ifa07d)

Bug Fixes

  • Fixed the crash when recording the video on some pre-Android O(API 26) devices. (I88fdf, b/212328261)
  • Fixed the incorrect AF region issue when using cameraControl#startFocusAndMetering() on front lens-facing camera in Samsung devices (Ifbf59, b/210548792)
  • Use torch as flash on Pixel 3a/Pixel 3a XL to improve the speed and the captured image quality in dark (Ib12b6, b/211474332)
  • Enabled applications to resume the camera when camera is interrupted by other higher priority application in the multi-window mode and the focus changes back to the application. Please note that there could be some latency(1 second to 10 seconds or more) between focus changes and camera reopened due to some framework issue. (I4d092)

Car App: v1.2.0-beta02

January 26, 2022

androidx.car.app:app-*:1.2.0-beta02 is released. Version 1.2.0-beta02 contains these commits.

Car apps built with this library version targeting the Android Automotive OS platform can now be published to the Play Store open testing channel. Refer to the development guide for more details.

Features annotated with API level 4 and under are compatible with both Android Auto 7.2+ and the new Android Automotive OS platform. See the Known Issues section below for caveats.

API Changes

  • Added experimental setOnContentRefreshListener API to POI templates (I6bf22)

Bug Fixes

  • Fixed a memory leak in CarAppService when the car host unbinds. (I5c9ca, b/203594731)
  • Updated CarAppActivity javadoc to include requirements for singleTask launchmode (Id2f95)
  • Reduces the visual glitch on resume. (Iff7e0)

Known Issue(s)

  • The map ActionStrips in the PlaceListNavigationTemplate and RoutePreviewNavigateTemplate will start becoming available in the next Android Auto and Android Automotive OS releases.

Compose Animation: v1.1.0-rc03

January 26, 2022

androidx.compose.animation:animation:1.1.0-rc03, androidx.compose.animation:animation-core:1.1.0-rc03, and androidx.compose.animation:animation-graphics:1.1.0-rc03 are released. Version 1.1.0-rc03 contains these commits.

Bug Fixes

  • Updated to support Compose Material 1.1.0-rc03

Compose Compiler: v1.1.0-rc03

January 26, 2022

androidx.compose.compiler:compiler:1.1.0-rc03 is released. Version 1.1.0-rc03 contains these commits.

Bug Fixes

  • Updated to support Compose Material 1.1.0-rc03

Compose Foundation: v1.1.0-rc03

January 26, 2022

androidx.compose.foundation:foundation:1.1.0-rc03 and androidx.compose.foundation:foundation-layout:1.1.0-rc03 are released. Version 1.1.0-rc03 contains these commits.

Bug Fixes

  • Updated to support Compose Material 1.1.0-rc03

Compose Material: v1.1.0-rc03

January 26, 2022

androidx.compose.material:material-*:1.1.0-rc03 is released. Version 1.1.0-rc03 contains these commits.

Behaviour Changes

Note that, with respect to Compose 1.0, Material components will expand their layout space to meet Material accessibility guidelines touch target size. For instance, Button touch target will expand to a minimum size of 48x48dp, even if you set the Button's size to be smaller. This aligns Compose Material to the same behavior of Material Design Components, providing consistent behavior if you mix Views and Compose. This change also ensures that when you create your UI using Compose Material components, minimum requirements for touch target accessibility will be met.

Bug Fixes

  • Added some better debug information for the layout inspector when inspecting minimum touch target modifiers. (aosp/1955036)

Compose Runtime: v1.1.0-rc03

January 26, 2022

androidx.compose.runtime:runtime-*:1.1.0-rc03 is released. Version 1.1.0-rc03 contains these commits.

Bug Fixes

  • Updated to support Compose Material 1.1.0-rc03

Compose UI: v1.1.0-rc03

January 26, 2022

androidx.compose.ui:ui-*:1.1.0-rc03 is released. Version 1.1.0-rc03 contains these commits.

Bug Fixes

  • Updated to support Compose Material 1.1.0-rc03

Compose Animation: v1.2.0-alpha02

January 26, 2022

androidx.compose.animation:animation:1.2.0-alpha02, androidx.compose.animation:animation-core:1.2.0-alpha02, and androidx.compose.animation:animation-graphics:1.2.0-alpha02 are released. Version 1.2.0-alpha02 contains these commits.

Compose Compiler: v1.2.0-alpha02

January 26, 2022

androidx.compose.compiler:compiler:1.2.0-alpha02 is released. Version 1.2.0-alpha02 contains these commits.

Compose Foundation: v1.2.0-alpha02

January 26, 2022

androidx.compose.foundation:foundation:1.2.0-alpha02 and androidx.compose.foundation:foundation-layout:1.2.0-alpha02 are released. Version 1.2.0-alpha02 contains these commits.

API Changes

  • Added NonRestartableComposable to methods that are overloads of existing methods without complex logic. This reduces compiler generated memoization checks (equals) for all parameters which are repeated in the inner function that is called. (I90490)
  • Added excludeFromSystemGesture Modifiers for easy access to Android's setSystemGestureExclusionRects (I46f07)

Bug Fixes

  • Text selection magnifier behavior has been polished to match the platform magnifier. (Idd918, b/206833278)
  • LazyColumn, LazyRow, Modifier.verticalScroll and other containers that use Modifier.scrollable now support mouse wheel scrolling. (I2b5e1, b/198214718)

Compose Material: v1.2.0-alpha02

January 26, 2022

androidx.compose.material:material-*:1.2.0-alpha02 is released. Version 1.2.0-alpha02 contains these commits.

API Changes

  • Added NonRestartableComposable to methods that are overloads of existing methods without complex logic. This reduces compiler generated memoization checks (equals) for all parameters which are repeated in the inner function that is called. (I90490)
  • Add support for action chip (I07100, b/192585545)

Compose Material 3: v1.0.0-alpha04

January 26, 2022

androidx.compose.material3:material3:1.0.0-alpha04 is released. Version 1.0.0-alpha04 contains these commits.

API Changes

  • Added NonRestartableComposable to methods that are overloads of existing methods without complex logic. This reduces compiler generated memoization checks (equals) for all parameters which are repeated in the inner function that is called. (I90490)
  • Added Material 3 divider. (Ica5fc)
  • Mark the Checkbox and RadioButton with an experimental API annotation. (Ie44bb)
  • Added support for Material 3 progress indicators. (Iff232, b/205023841)

Bug Fixes

  • Update a disabled TextButton's container color to be transparent (I6b248, b/213339737)

Compose Runtime: v1.2.0-alpha02

January 26, 2022

androidx.compose.runtime:runtime-*:1.2.0-alpha02 is released. Version 1.2.0-alpha02 contains these commits.

Compose UI: v1.2.0-alpha02

January 26, 2022

androidx.compose.ui:ui-*:1.2.0-alpha02 is released. Version 1.2.0-alpha02 contains these commits.

API Changes

  • Added Modifier.onRotaryScrollEvent() and Modifier.onPreRotaryScrollEvent() for wear devices with a rotating side button (I18bf5, b/210748686)
  • Add experimental View.createLifecycleAwareRecomposer extension (I0cde6)

External Contribution

  • PointerEvent.scrollDelta.y is now inverted on Android (now it returns 1 instead of -1 if we tilt mouse wheel to the right) (Ia9811)

Core and Core-ktx: v1.8.0-alpha03

January 26, 2022

androidx.core:core:1.8.0-alpha03 and androidx.core:core-ktx:1.8.0-alpha03 are released. Version 1.8.0-alpha03 contains these commits.

API Changes

  • Converted WindowInsetsControllerCompat to depend on a View instead of a Window or the platform WindowInsetsController. This improves behavior with Dialogs, showing the IME, and ensures the non-deprecated creation methods workaround (b/180881870). (I29264, b/207401542, b/210121779)
  • Cleaned up nullability for a subset of androidx.core APIs. (Ib2583, b/206113818)
  • Fixed nullability of performAccessibilityAction params (Ibbafe)
  • Added method for working around ColorStateList issues resulting from Theme-keyed caching and Theme.applyStyle (I9188b, b/207739887)
  • Update shortcut visibility api for better readability (Ia58df)
  • Added zero-arg overload for persistableBundleOf() to avoid an unnecessary array allocation when creating an empty PersistableBundle (Icd7a4)

Core Remote Views: v1.0.0-alpha02

January 26, 2022

androidx.core:core-remoteviews:1.0.0-alpha02 is released. Version 1.0.0-alpha02 contains these commits.

DragAndDrop: v1.0.0-alpha03

January 26, 2022

androidx.draganddrop:draganddrop:1.0.0-alpha03 is released. Version 1.0.0-alpha03 contains these commits.

New Features

  • On devices running Android S or later, DropHelper now delegates to the system implementation of OnReceiveContentListener, automatically providing support for input methods other than drag and drop.

Emoji2: v1.1.0-beta01

January 26, 2022

androidx.emoji2:emoji2-*:1.1.0-beta01 is released. Version 1.1.0-beta01 contains these commits.

Bug Fixes

  • androidx-emoji2 beta01 release. No changes from alpha01 (Ic61d9)

Fragment: v1.4.1

January 26, 2022

androidx.fragment:fragment:1.4.1, androidx.fragment:fragment-ktx:1.4.1, and androidx.fragment:fragment-testing:1.4.1 are released. Version 1.4.1 contains these commits.

Bug Fixes

  • FragmentContainerView no longer throws an illegal state exception when view IDs generated from xml have negative values. (Ic185b, b/213086140)
  • When using a custom ownerProducer lambda with the by viewModels() lazy function, it will now use the defaultViewModelProviderFactory from that owner if a custom ViewModelProvider.Factory is not provided instead of always using the fragment's factory. (I56170, b/214106513)

Fragment: v1.5.0-alpha01

January 26, 2022

androidx.fragment:fragment:1.5.0-alpha01, androidx.fragment:fragment-ktx:1.5.0-alpha01, and androidx.fragment:fragment-testing:1.5.0-alpha01 are released. Version 1.5.0-alpha01 contains these commits.

New Features

Bug Fixes

  • From Fragment 1.4.1: FragmentContainerView no longer throws an illegal state exception when view IDs generated from xml have negative values. (Ic185b, b/213086140)
  • From Fragment 1.4.1: When using a custom ownerProducer lambda with the by viewModels() lazy function, it will now use the defaultViewModelProviderFactory from that owner if a custom ViewModelProvider.Factory is not provided instead of always using the fragment's factory. (I56170, b/214106513)
  • Fixed a crash when accessing a ViewModelfor the very first time from a registerForActivityResult() callback of a Fragment. (Iea2b3)

Games-Activity: v1.1.0-beta03

January 26, 2022

androidx.games:games-activity:1.1.0-beta03 is released. Version 1.1.0-beta03 contains these commits.

Bug Fixes

  • Fix signature of onNativeWindowResized
  • Maintain handle to native window in onSurfaceChanged

Games-Controller: v1.1.0-beta01

January 26, 2022

androidx.games:games-controller:1.1.0-beta01 is released with no changes since 1.1.0-alpha01. Version 1.1.0-beta01 contains these commits.

Games Frame Pacing 1.10: v1.10.0-beta01

January 26, 2022

androidx.games:games-frame-pacing:1.10.0-beta01 is released. Version 1.10.0-beta01 contains these commits.

Games Performance Tuner 1.5.0: v1.5.0-rc01

January 26, 2022

androidx.games:games-performance-tuner:1.5.0-rc01 is released. Version 1.5.0-rc01 contains these commits.

Bug Fixes

  • Fix for memory corruption in API key on API<=23

Games-Text-Input: v1.1.0-rc01

January 26, 2022

androidx.games:games-text-input:1.1.0-rc01 is released. Version 1.1.0-rc01 contains these commits.

Glance: v1.0.0-alpha02

January 26, 2022

androidx.glance:glance-*:1.0.0-alpha02 is released. Version 1.0.0-alpha02 contains these commits.

New Features

This release contains the set of APIs to build Wear Tiles using Compose runtime with composables optimized for "Glanceable"

  • Declare your wear tile service by extending GlanceTileService, a service to create your tile in the composable Content() function.
  • Wear tiles specific glance composables: CurvedRow, CurvedText.
  • Handle different timeline modes for tile by defining TimelineMode.SingleEntry and TimelineMode.TimeBoundEntries.
  • LocalTimeInterval, the Local composition refer to a specific time interval.
  • BorderModifer is a GlanceModifier applying a border around an element.

This release also adds Progress Indicators to AppWidget Glance.

API Changes

  • Added LinearProgressIndicator and CircularProgressIndicator composable. (Ie116b)
  • Change actionStartBroadcastReceiver to actionSendBroadcast (I7d555)
  • Pass Context to GlanceAppWidget onDelete callback (I4c795)

Bug Fixes

  • Correct handling of OPTIONS_APPWIDGET_SIZES if present but empty. (I01f82)

Hilt-Navigation-Compose: v1.0.0

January 26, 2022

androidx.hilt:hilt-navigation-compose:1.0.0 is released. Version 1.0.0 contains these commits.

Major features of 1.0.0

The androidx.hilt:hilt-navigation-compose artifact provides APIs that allow users to get a @HiltViewModel annotated ViewModel from a Navigation back stack entry within a Compose application using :navigation-compose.

The function hiltViewModel() returns an existing ViewModel or creates a new one scoped to the current navigation graph present on the NavController back stack. The function can optionally take a NavBackStackEntry to scope the ViewModel to a parent back stack entry.

Lifecycle: v2.5.0-alpha01

January 26, 2022

androidx.lifecycle:lifecycle-*:2.5.0-alpha01 is released. Version 2.5.0-alpha01 contains these commits.

ViewModel CreationExtras

With this release, we are laying the groundwork for restructuring how a ViewModel is constructed. Instead of a rigid set of subclasses of ViewModelProvider.Factory that each add additional functionality (allowing an Application constructor parameter via AndroidViewModelFactory, allowing a SavedStateHandle constructor parameter via SavedStateViewModelFactory and AbstractSavedStateViewModelFactory, etc.), we are moving to a world of stateless factories that rely on a new concept, CreationExtras. (Ia7343, b/188691010, b/188541057)

With this change, ViewModelProvider no longer makes direct calls into the previous create(Class<T>) method of ViewModelProvider.Factory. Instead, it calls into a new overload of create: create(Class<T>, CreationExtras). This means that any direct implementation of the ViewModelProvider.Factory instance now has access to each of these new CreationExtras:

  • ViewModelProvider.NewInstanceFactory.VIEW_MODEL_KEY: this String provides access to the custom key you passed to ViewModelProvider.get().
  • ViewModelProvider.AndroidViewModelFactory.APPLICATION_KEY provides access to the Application class.
  • SavedStateHandleSupport.SAVED_STATE_REGISTRY_OWNER_KEY provides access to the SavedStateRegistryOwner that is being used to construct this ViewModel.
  • SavedStateHandleSupport.VIEW_MODEL_STORE_OWNER_KEY provides access to the ViewModelStoreOwner that is being used to construct this ViewModel.
  • SavedStateHandleSupport.DEFAULT_ARGS_KEY provides access to the Bundle of arguments that should be used to construct a SavedStateHandle.

These extras are provided by default when using Activity 1.5.0-alpha01, Fragment 1.5.0-alpha01, and Navigation 2.5.0-alpha01. If you use an earlier version of those libraries, your CreationExtras will be empty - all of the existing subclasses of ViewModelProvider.Factory have been rewritten to support both the legacy creation path used by earlier versions of those libraries and the CreationExtras path which will be used going forward.

These CreationExtras allow you to construct a ViewModelProvider.Factory that passes just the information you need to each ViewModel without relying on a strict hierarchy of Factory subclasses:

class CustomFactory : ViewModelProvider.Factory {
    override fun <T : ViewModel> create(modelClass: Class<T>, extras: CreationExtras): T {
        return when (modelClass) {
            HomeViewModel::class -> {
                // Get the Application object from extras
                val application = checkNotNull(extras[ViewModelProvider.AndroidViewModelFactory.APPLICATION_KEY])
                // Pass it directly to HomeViewModel
                HomeViewModel(application)
            }
            DetailViewModel::class -> {
                // Create a SavedStateHandle for this ViewModel from extras
                val savedStateHandle = extras.createSavedStateHandle()
                DetailViewModel(savedStateHandle)
            }
            else -> throw IllegalArgumentException("Unknown class $modelClass")
        } as T
    }
}

We use the createSavedStateHandle() Kotlin extension function on CreationExtras from SavedStateHandleSupport to construct a SavedStateHandle only for the one ViewModel that needs it. (Ia6654, b/188541057)

Custom CreationExtras can be provided by overriding getDefaultViewModelCreationExtras() in your ComponentActivity or Fragment, thus making them available to your custom ViewModelProvider.Factory as a built in form of assisted injection. These extras will automatically be made available to your custom Factory when used directly with ViewModelProvider or when using the by viewModels() and by activityViewModels() Kotlin property extensions. (I79f2b, b/207012584, b/207012585, b/207012490)

Bug Fixes

  • Fixed an issue where the default value provided to a SavedStateHandle would reappear after process death and recreation, even if it was specifically removed from the SavedStateHandle. As a consequence of this, SavedStateHandle will no longer merge default values and restored values together, instead only using the restored values as the source of truth. (I53a4b)

Media: v1.5.0-rc01

January 26, 2022

androidx.media:media:1.5.0-rc01 is released with no changes since 1.5.0-beta01. Version 1.5.0-rc01 contains these commits.

Mediarouter: v1.2.6

January 26, 2022

androidx.mediarouter:mediarouter:1.2.6 is released. Version 1.2.6 contains these commits.

Bug Fixes

  • Fix RemotePlaybackClient constructor crash on Android 12 b/210684559

Navigation: v2.5.0-alpha01

January 26, 2022

androidx.navigation:navigation-*:2.5.0-alpha01 is released. Version 2.5.0-alpha01 contains these commits.

New Features

Bug Fixes

  • Fixed an issue where accessing a ViewModel created via by navGraphViewModels() from a Fragment's onCreate() would fail with an IllegalStateException. (I8a14d)
  • NavDeepLinks will no longer unnecessarily decode args twice, meaning that the proper args are now passed to your final destination. (I31b0a, b/210711399)

Safe Args

  • Safe Args now depends on Android Gradle Plugin version 7.0.4. This means that Navigation Safe Args will no longer be compatible with Android Studio versions prior to 7.0, but is now compatible with Android Gradle Plugin 7.1.0 and higher. (I41c88, b/213086135, b/207670704)

Navigation: v2.4.0

January 26, 2022

androidx.navigation:navigation-*:2.4.0 is released. Version 2.4.0 contains these commits.

Important changes since 2.3.0

  • All Navigation artifacts have been rewritten in Kotlin. This has improved the nullability of classes using generics (such as NavType subclasses). All Kotlin extension functions that used to be part of the -ktx artifacts have been moved to their respective main artifacts. The -ktx artifacts will continue to be published, but are completely empty.
  • The navigation-fragment artifact now contains a prebuilt implementation of a two pane layout via the new AbstractListDetailFragment. This fragment uses a SlidingPaneLayout to manage a list pane (which your subclass provides) and a detail pane, which uses a NavHostFragment as its implementation, as seen in our example implementation.
  • The currentBackStackEntryAsFlow() method on NavController provides a Flow that emits whenever the current NavBackStackEntry changes. This flow can be used as an alternative to manually managing an OnDestinationChangedListener.
  • NavController now offers the ability to retrieve a list of all visible NavBackStackEntry instances as a StateFlow via the experimental visibleEntries property.
  • It is now possible to extend the NavType class to create custom NavTypes. Custom types are supported only when building your navigation graph programmatically, such as via the Navigation Graph Kotlin DSL.
  • Navigation now providesfindStartDestination() and getHierarchy() APIs that can be used to help implement custom NavigationUI. findStartDestination() is an extension function on NavGraph that will locate the actual start destination that will be displayed when you navigate to the graph, even if the startDestination is itself a nested NavGraph. getHierarchy() is a function on NavDestination that can be used to verify if a given destination is within the hierarchy of another.

    val matchingRoute: Boolean = destination.hierarchy.any { it.route == routeToFind }
    
  • NavigationUI methods that took a BottomNavigationView have been updated to instead take its superclass introduced in Material 1.4.0, NavigationBarView. This allows these methods to be used with the NavigationRailView.

  • When inflating an <action> element via XML, animation attributes can use attributes pulled from your theme using the app:enterAnim="?attr/transitionEnter" syntax.

  • Safe Args now generates a fromSavedStateHandle() method for each NavArgs class. (#122, b/136967621)

    class HomeViewModel(savedStateHandle: SavedStateHandle) : ViewModel() {
      // Create a HomeDestinationArgs class with type safe accessors for each argument
      // defined on your destination
      private val args = HomeDestinationArgs.fromSavedStateHandle(savedStateHandle)
    }
    

Navigation Routes and the Kotlin DSL

Previous versions of Navigation relied on each destination having a constant integer ID that would uniquely identify it from its sibling destinations and allow you to navigate() to that destination either directly or via an action. While this continues to be valid and useful, particularly in cases where you are defining your navigation graph in XML and can use auto-generated R.id constants or Safe Args (which uses those constants to generate code at build time), this system of unique integers did not capture the semantic meaning and expressiveness needed to support fully dynamic graphs built programmatically at runtime via the Navigation Kotlin DSL.

This release introduces a new option for uniquely identifying a destination in a navigation graph by its route. A route is a String that defines the unique path to a destination. All Kotlin DSL methods that took a destination ID are now deprecated and replaced with an equivalent API that takes a route.

Each route should be treated as the ‘path’ part of a Uri that defines that destination, e.g., home, profile/{userId}, profile/{userId}/friends, etc. When the identity of a destination is associated with a specific piece of content, those dynamic arguments should be part of the route, following the same rules as implicit deep links.

All NavController APIs that used to only take an ID now have an overload that takes a route String. This includes navigate(), popBackStack(), popUpTo(), and getBackStackEntry().

This has had some API implications:

  • The popUpTo Kotlin property on the Kotlin DSL has been deprecated in favor of popUpToId.
  • The getStartDestination() API has been deprecated in favor of getStartDestinationId().

Unlike when navigating by ID, navigating by route follows the same rules as implicit deep links in that you can directly navigate to any destination in any nested graph, ensuring that these routes are usable in multi-module projects without explicitly adding an externally visible deep link to each destination.

Navigation Compose

The navigation-compose artifact provides integration between the Navigation Component and Jetpack Compose. It uses @Composable functions as the destinations in your application.

This release provides:

  • A NavHost composable that allows you to construct your navigation graph via a Kotlin DSL, using composable and dialog destinations, plus support for optional Navigators such as those from Accompanist Navigation Material.
  • Mandatory support for crossfading between destinations. Accompanist Navigation Animation can be used to control the enter and exit transitions using experimental Compose APIs.
  • Scoping of a Lifecycle to each composable destination. Each destination only reaches the RESUMED state when any entering transitions finish and immediately drops to STARTED when any exiting transitions start, thus allowing you to avoid all IllegalStateException and multi-touch issues by only triggering a navigate call when the Lifecycle is RESUMED.
  • Scoping of ViewModel (via the viewModel() API of Lifecycle ViewModel Compose 2.4.0 or hiltViewModel() of Hilt Navigation Compose 1.0.0 at the destination level, providing a scope that survives configuration changes and being on the back stack (when your Composable content is otherwise disposed) and a signal in the ViewModel’s onCleared() that indicates the permanent disposal and cleaning up of state associated with that NavBackStackEntry.
  • Scoping of rememberSaveable state at a destination level, ensuring that all composable state is saved and restored automatically when you return to a destination.
  • Full support for saving and restoring the state of the NavController and its destination’s state after process death and recreation.
  • Automatic integration with the system back button.
  • Support for passing arguments, attaching deep links to destinations, and returning a result to previous destinations.

  • Compose specific helpers in rememberNavController() and currentBackStackEntryAsState() to allow hoisting state and connecting the NavController to composables outside of the NavHost (such as a bottom navigation bar).

val navController = rememberNavController()
Scaffold { innerPadding ->
    NavHost(navController, "home", Modifier.padding(innerPadding)) {
        composable("home") {
            // This content fills the area provided to the NavHost
            HomeScreen()
        }
        dialog("detail_dialog") {
            // This content will be automatically added to a Dialog() composable
            // and appear above the HomeScreen or other composable destinations
            DetailDialogContent()
        }
    }
}

See the Compose Navigation guide for more information.

Multiple back stacks

The NavController is responsible for managing the back stack of destinations, adding destinations to the back stack when you navigate() to them and removing them when you call popBackStack() or trigger the system back button. The existing NavOptions class and the integration into <action> elements in the navigation graph XML has been expanded to support saving and restoring the back stack.

As part of this change, the NavigationUI methods of onNavDestinationSelected(), BottomNavigationView.setupWithNavController() and NavigationView.setupWithNavController() now automatically save and restore the state of popped destinations, enabling support for multiple back stacks without any code changes. When using Navigation with Fragments, this is the recommended way to integrate with multiple back stacks.

The underlying APIs for saving and restoring the state are exposed via a number of surfaces:

  • In Navigation XML, the <action> element can now use the boolean attributes of app:popUpToSaveState and app:restoreState to save the state of any destinations popped via app:popUpTo and restore the state associated with the destination passed as the app:destination:

    <action
      android:id=”@+id/swap_stack”
      app:destination=”@id/second_stack”
      app:restoreState=”true”
      app:popUpTo=”@id/first_stack_start_destination”
      app:popUpToSaveState=”true” />
    
  • In the navOptions Kotlin DSL, you can add the restoreState boolean property and the saveState boolean property on the popUpTo builder:

    // Use the navigate() method that takes a navOptions DSL Builder
    navController.navigate(selectedBottomNavRoute) {
      launchSingleTop = true
      restoreState = true
      popUpTo(navController.graph.findStartDestination().id) {
        saveState = true
      }
    }
    
  • In manually building a NavOptions object via the NavOptions.Builder, you can use the setRestoreState() and new overload to setPopUpTo() that takes an additional saveState parameter.

    NavOptions navOptions = new NavOptions.Builder()
      .setLaunchSingleTop(true)
      .setRestoreState(true)
      .setPopUpTo(NavGraph.findStartDestination(navController.getGraph()).getId(),
        false, // inclusive
        true) // saveState
      .build();
    navController.navigate(selectedBottomNavId, null, navOptions);
    
  • Programmatic calls to popBackStack() can now include an additional saveState parameter.

  • You can use the clearBackStack() method to clear any state that was saved with popBackStack() or popUpToSaveState.

In all cases, the NavController will save and restore the state of each NavBackStackEntry, including any navigation destination scoped ViewModel instances. The Navigator APIs have been updated to enable each Navigator to support saving and restoring their own state.

Behavior changes

  • NavDeepLinkBuilder now adds PendingIntent.FLAG_IMMUTABLE to the PendingIntent returned by createPendingIntent(), ensuring that this API works as expected when targeting Android 12.
  • Navigation now depends on Lifecycle 2.3.1 and now marks setGraph(), popBackStack(), navigateUp(), and navigate(), the methods that update the NavBackStackEntry Lifecycle, as @MainThread, aligning Navigation with the main thread enforcement introduced in Lifecycle 2.3.0.
  • Deep links now verify that all required arguments (those without default values) are present in the Uri.
  • NavDeepLink parsed arguments now consider pound signs in the same way as question marks as a separator between path segments, preventing an argument from spanning across the pound sign.
  • When generating actions, Kotlin code generated from Safe Args now puts arguments without default values before those with default values as parameters.
  • When generating arguments, Safe Args now puts parameters without default values before those with default values.
  • Safe-Args now depends on Android Gradle Plugin 4.2.0. This means you should no longer get the using applicationIdTextResource warning.

Known issues

  • Fixed in Navigation 2.5.0-alpha01: accessing a ViewModel created via by navGraphViewModels() from a Fragment's onCreate() will fail with an IllegalStateException. (b/213504272)
  • Fixed in Navigation 2.5.0-alpha01: Safe Args 2.4.0 is incompatible with Android Gradle Plugin 7.1.0 and higher. (b/213086135)
  • Deep linking with multiple nested nav graphs doesn't correctly create the full backstack. (b/(b/214383060)

Preference: v1.2.0

January 26, 2022

androidx.preference:preference:1.2.0 and androidx.preference:preference-ktx:1.2.0 are released. Version 1.2.0 contains these commits.

Important changes since 1.1.0

  • Added PreferenceHeaderFragmentCompat for two-pane preference that automatically adapts based on size of the device used, making it suitable for use on phones, foldables, and tablets. The header pane is provided by overriding the onCreatePreferenceHeader() method on PreferenceHeaderFragmentCompat. Any <Preference> in the header PreferenceFragmentCompat that uses app:fragment will cause that fragment to appear in the second detail pane. The initial detail fragment that should be displayed before any preference is manually selected can be customized by overriding onCreateInitialDetailFragment(). The default implementation returns the first preference that has a fragment defined on it.
class TwoPanePreference : PreferenceHeaderFragmentCompat() {
    override fun onCreatePreferenceHeader(): PreferenceFragmentCompat {
        return PreferenceHeader()
    }
}
  • Added nullability annotations to many of the APIs that previously did not specify @NonNull or @Nullable. This is a potentially Kotlin source breaking change if the nullability you had chosen in your Kotlin code did not match the nullability that is now defined.

  • PreferenceFragmentCompat’s now looks for implementations of the OnPreferenceStartFragmentCallback, OnNavigateToScreenListener, and OnDisplayPreferenceDialogListener interface on parent fragments before looking to see if the hosting Context or Activity implement these interfaces.

ProfileInstaller: v1.2.0-alpha02

January 26, 2022

androidx.profileinstaller:profileinstaller:1.2.0-alpha02 is released. Version 1.2.0-alpha02 contains these commits.

This version is identical to 1.2.0-alpha01.

ResourceInspection: v1.0.1

January 26, 2022

androidx.resourceinspection:resourceinspection-annotation:1.0.1 and androidx.resourceinspection:resourceinspection-processor:1.0.1 are released. Version 1.0.1 contains these commits.

Bug Fixes

  • Added package documentation

Savedstate: v1.2.0-alpha01

January 26, 2022

androidx.savedstate:savedstate:1.2.0-alpha01 and androidx.savedstate:savedstate-ktx:1.2.0-alpha01 are released. Version 1.2.0-alpha01 contains these commits.

New Features

  • SavedStateRegistryController now allows early attachment of the SavedStateRegistry via performAttach(). (Ice4bf)

Behavior Changes

Slidingpanelayout: v1.2.0

January 26, 2022

androidx.slidingpanelayout:slidingpanelayout:1.2.0 is released. Version 1.2.0 contains these commits.

Important changes since 1.1.0

  • SlidingPaneLayout is now fold-aware. On a foldable device, SlidingPaneLayout will automatically adjust the size of the two panes so that the panes are on either side of the fold, hinge, etc.
  • When handling your own configuration changes, - SlidingPaneLayout now animates between the single pane and two pane modes when the amount of space provided changes (i.e., when unfolding a foldable device).
  • SlidingPaneLayout now has a new UI styling when the two panes overlap. Each pane will now extend from edge to edge, with the detail or secondary pane fully covering the list or primary pane when the SlidingPaneLayout is open. APIs specific to the old UI styling, such as the fade color, have been deprecated.
  • SlidingPaneLayout now defaults to ‘closed’ - i.e., showing the list or primary pane. Calling open() or openPane() will now show the detail or secondary pane.
  • Improved compatibility with additional measure specs to ensure that SlidingPaneLayout can be used in any type of layout without throwing an IllegalStateException.
  • SlidingPaneLayout now allows registering multiple PanelSlideListeners.
  • Developers can now control whether users can swipe between the list and detail panes by setting a lock mode.

Wear Compose: v1.0.0-alpha15

January 26, 2022

androidx.wear.compose:compose-foundation:1.0.0-alpha15, androidx.wear.compose:compose-material:1.0.0-alpha15, and androidx.wear.compose:compose-navigation:1.0.0-alpha15 are released. Version 1.0.0-alpha15 contains these commits.

API Changes

  • We have added a new property autoCentering to the ScalingLazyColumn. When true (the default) this will ensure that all items including the first and last can be scrolled so that they are visible in the center of the lists viewport. Note that if using auto-centering you will probably want to set vertical content padding to 0.dp. If both autoCentering and vertical content padding are provided then they will both result in additional space being available before the first and after the last list items allowing them to be scrolled even further. (I2a282, b/214922490)
  • We have added a Dialog component that enables any composable to trigger a full screen dialog that sits on top of other content. When shown, the dialog supports swipe-to-dismiss and will show its parent's content in the background during the swipe gesture. The dialog content is expected to be Alert or Confirmation (renamed from earlier components AlertDialog and ConfirmationDialog) - Alert, Confirmation and Dialog are all in the androidx.wear.compose.material.dialog package. Alert and Confirmation can be used as navigation destinations. Also, added ColumnScope to Alert and Confirmation parameters as necessary. (Ia9014)
  • We have removed onSurfaceVariant2 from the Compose for WearOS Material Theme Colors and replaced uses in the library with onSurfaceVariant. (Icd592)
  • Added a method to programmatically select an option on the PickerState, the initially selected option can now also be specified when creating a PickerState. (I92bdf)
  • We have added support for customizing the fling behavior of the ScalingLazyColumn. (I1ad2e, b/208842968)
  • We have added NavController.currentBackStackEntryAsState() to the Wear.Compose.Navigation library. (If9028, b/212739653)
  • Added Modifier.onRotaryScrollEvent() and Modifier.onPreRotaryScrollEvent() for Wear devices with a rotating side button.(I18bf5, b/210748686)

Wear Tiles: v1.1.0-alpha01

January 26, 2022

androidx.wear.tiles:tiles-*:1.1.0-alpha01 is released. Version 1.1.0-alpha01 contains these commits.

New Features

  • The new library Tiles Material has been added. It contains components to build Tiles layouts faster and easier with Material design. Initial components are:
    • Button
    • Chip
    • CompactChip
    • TitleChip

Bug Fixes

  • Fix bug in TileUiClient which led to cached resources being discarded. (I60e0b)

Wear Tiles: v1.0.1

January 26, 2022

androidx.wear.tiles:tiles-*:1.0.1 is released. Version 1.0.1 contains these commits.

Bug Fixes

  • Fix bug in TileUiClient which led to cached resources being discarded. (I60e0b)

WindowManager: v1.0.0

January 26, 2022

androidx.window:window-*:1.0.0 is released. Version 1.0.0 contains these commits.

Major features of 1.0.0

  • Support for folding phones through WindowInfoTracker and FoldingFeature. WindowMetricsCalculator to help calculate the current WindowMetrics.