Fragment

Latest Update Current Stable Release Next Release Candidate Beta Release Alpha Release
December 4, 2019 1.1.0 1.2.0-rc03 - -

Declaring dependencies

To add a dependency on Fragment, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.

Add the dependencies for the artifacts you need in the build.gradle file for your app or module:

dependencies {
    def fragment_version = "1.1.0"

    // Java language implementation
    implementation "androidx.fragment:fragment:$fragment_version"
    // Kotlin
    implementation "androidx.fragment:fragment-ktx:$fragment_version"
    // Testing Fragments in Isolation
    implementation "androidx.fragment:fragment-testing:$fragment_version"
}

For more information about dependencies, see Add build dependencies.

Version 1.2.0

Version 1.2.0-rc03

December 4, 2019

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

Bug fixes

  • Fixed an unintentional behavior change where Fragments who have been removed are still returned by findFragmentById() / findFragmentByTag() while their exit animations/transitions run. (b/143982969, aosp/1167585)
  • Child fragments are now correctly stopped before their parents when the containing activity calls onSaveInstanceState(). (b/144380645)
  • Fixed an issue where Views were incorrectly marked INVISIBLE after popping a hidden Fragment. (b/70793925)
  • Fragment shared element transitions now handle Views that have been rotated, scaled, etc. (b/142835261)

Documentation Updates

  • Clarified the deprecation documentation around setUserVisibleHint(). (b/143897055)
  • Improved the documentation on setFragmentFactory() and getFragmentFactory() to better indicate that setting a FragmentFactory will also affect child FragmentManagers. (aosp/1170095)

Dependency changes

  • Fragments now depends on Lifecycle 2.2.0-rc03, Lifecycle ViewModel SavedState 1.0.0-rc03, and Activity 1.1.0-rc03.

Version 1.2.0-rc02

November 7, 2019

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

Bug fixes

  • When in Kotlin, the LintFix for using getViewLifecycleOwner() when observing LiveData from onCreateView(), onViewCreated(), or onActivityCreated() (introduced in Fragment 1.2.0-rc01) now uses the Kotlin property access syntax viewLifecycleOwner instead of getViewLifecycleOwner(). (aosp/1143821)

Version 1.2.0-rc01

October 23, 2019

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

New features

  • FragmentContainerView now supports the class attribute in addition to android:name, mirroring the functionality of the <fragment> tag. (b/142722242)
  • Added a new Lint check that ensures you are using getViewLifecycleOwner() when observing LiveData from onCreateView(), onViewCreated(), or onActivityCreated(). (b/137122478)

Bug fixes

  • The onDismiss and onCancel callbacks on DialogFragment now guarantee that the DialogInterface passed to them is non-null and that getDialog() returns non-null when they are executed. (b/141974033)
  • FragmentContainerView now adds the Fragment defined by class or android:name as part of inflation, ensuring that findFragmentById() and findFragmentByTag() work immediately afterwards. (b/142520327)
  • Fixed an IllegalStateException in FragmentContainerView due to the state being saved. (b/142580713)
  • Fixed an UnsupportedOperationException in FragmentContainerView when the FragmentContainerView class is obfuscated. (b/142657034)

Known issues

  • Fragments referenced only via the class or android:name attribute on a FragmentContainerView are not kept by ProGuard automatically, requiring that you manually add a keep rule for each fragment class. We have disabled the Lint rule suggesting moving to FragmentContainerView until this is fixed via aapt2. (b/142601969)

Version 1.2.0-beta02

October 11, 2019

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

Bug fixes

  • Fixed an issue where Fragment's onInflate() did not receive proper attributes from FragmentContainerView, breaking cases such as NavHostFragment. (b/142421837)

Version 1.2.0-beta01

October 9, 2019

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

New features

  • FragmentContainerView adds support for adding an initial fragment with added support for the android:name and optional android:tag XML attributes. Unlike the <fragment> tag, FragmentContainerView uses a normal FragmentTransaction under the hood to add the initial fragment, allowing further FragmentTransaction operations on the FragmentContainerView and enables the usage of View Binding for the layout. (b/139830628, b/141177981)
  • Fragments now contains a Lint warning offering a quick fix to replace <fragment> with FragmentContainerView. (b/139830056)

Bug fixes

  • Fixed a ClassCastException when using androidx.transition. (b/140680619)
  • When using Transition 1.3.0-beta01, Fragments now wait for androidx.transition transitions (in addition to framework transitions and animations, which were fixed in Fragment 1.2.0-alpha03 and Fragment 1.2.0-alpha02, respectively) to finish before dispatching onDestroyView(). (aosp/1119841)
  • When using Transition 1.3.0-beta01, Fragments now properly cancel androidx.transition transitions before starting new transitions / animations on the same container. (aosp/1119841)
  • Fixed an issue on API 17 and lower when using androidx.transition transitions on the root view of your Fragment when using FragmentContainerView. (b/140361893)
  • The fragment-testing artifact now depends on AndroidX Test 1.2.0, fixing an incompatibility with the latest Espresso 3.2.0. (b/139100149)
  • Removed usage of Log.w in FragmentManager. (aosp/1126468)

Known issues

  • Fragment's onInflate() do not receive proper attributes from FragmentContainerView, breaking cases such as NavHostFragment. (b/142421837)

Version 1.2.0-alpha04

September 18, 2019

androidx.fragment:fragment:1.2.0-alpha04, androidx.fragment-ktx:example:1.2.0-alpha04, and androidx.fragment:fragment-testing:1.2.0-alpha04 are released. Version 1.2.0-alpha04 contains these commits.

API changes

  • The getFragmentManager() and requireFragmentManager() methods on Fragment have been deprecated and replaced with a single getParentFragmentManager() method, which returns the non-null FragmentManager the Fragment is added to (you can use isAdded() to determine if it is safe to call). (b/140574496)
  • The static FragmentManager.enableDebugLogging method has been deprecated. FragmentManager now respects Log.isLoggable() for the tag FragmentManager, allowing you to enable either DEBUG or VERBOSE logging without re-compiling your app. (aosp/1116591)

Bug fixes

  • Fragments are now properly destroyed while exit animations on other fragments are running. (b/140574199)
  • Fixed an issue where Fragments would call Activity.findViewById() where before it did not. (aosp/1116431)

Version 1.2.0-alpha03

September 5, 2019

androidx.fragment:fragment:1.2.0-alpha03, androidx.fragment:fragment-ktx:1.2.0-alpha03, and androidx.fragment:fragment-testing:1.2.0-alpha03 are released. The commits included in this version can be found here.

API changes

Bug fixes

  • FragmentContainerView now properly reverses the draw order when popping fragments off the back stack. (b/139104187)
  • Fixed an issue where the wrong animation would run when both popping a fragment and adding a new fragment at the same time. (b/111659726)
  • Fragments now wait for transitions (in addition to animations, which was fixed in Fragment 1.2.0-alpha02) to finish before dispatching onDestroyView(). (b/138741697)

Version 1.2.0-alpha02

August 7, 2019

androidx.fragment:fragment:1.2.0-alpha02, androidx.fragment:fragment-ktx:1.2.0-alpha02, and androidx.fragment:fragment-testing:11.2.0-alpha02 is released. The commits included in this version can be found here.

New features

  • SavedStateViewModelFactory is now the default factory used when using by viewModels(), by activityViewModels(), the ViewModelProvider constructor, or ViewModelProviders.of() with a Fragment. (b/135716331)
  • The default animations when using TRANSIT_FRAGMENT_OPEN, TRANSIT_FRAGMENT_CLOSE, TRANSIT_FRAGMENT_FADE with setTransition on a FragmentTransaction have been updated to match the animations used by activities on Android Q devices. (aosp/1012812, aosp/1014730)

API changes

  • Introduces FragmentContainerView as the strongly recommended container for dynamically added Fragments, replacing usage of FrameLayout, etc. as it fixes animation z-ordering issues and window insets dispatching to Fragments. (b/37036000, aosp/985243, b/136494650)
  • Added a static FragmentManager.findFragment(View) method to retrieve the containing Fragment from a view inflated by a fragment. A Kotlin extension is also available in fragment-ktx. (aosp/1090757)
  • Added new overloads of add() and replace() on FragmentTransaction that take a Class<? extends Fragment> and optional Bundle of arguments. These methods use your FragmentFactory to construct an instance of the Fragment to add. Kotlin extension that use reified types (i.e, fragmentTransaction.replace<YourFragment>(R.id.container)) have also been added to fragment-ktx. (b/126124987)
  • @MainThread annotations have been added to Fragment lifecycle callbacks. (b/127272564)
  • The breadcrumb title related APIs on FragmentTransaction and FragmentManager.BackStackEntry have been deprecated. (b/138252944)
  • The setTransitionStyle method on FragmentTransaction has been deprecated. (aosp/1011537)
  • Many of the methods in FragmentManager are no longer abstract. FragmentManager itself remains abstract and should not be directly instantiated or extended; you should continue to only get an existing instance from getSupportFragmentManager(), getChildFragmentManager(), etc.

Bug fixes

  • From Fragment 1.1.0-rc04: Fragments now correctly cancel postponed transitions on Fragments have been popped. (b/138251858)
  • From Fragment 1.1.0-rc03: Fixed an issue where calling postponeEnterTransition() with a timeout more than once would not cancel previous timeouts. (b/137797118)
  • From Fragment 1.1.0-rc02: Fixed a crash in FragmentPagerAdapter and FragmentStatePagerAdapter when removing the current item. (b/137209870)
  • Fragments now wait for animations to finish before dispatching onDestroyView(). (b/136110528)
  • Fragment animations from child fragments and their descendants are now properly handled when animating the parent Fragment. (b/116675313)
  • Fixed a NullPointerException when using shared element transitions and combining a pop and add operation. (b/120507394)
  • Added a workaround to IllegalStateExceptions when using FragmentPagerAdapter and FragmentStatePagerAdapter in Robolectric tests. (b/137201343)

Version 1.2.0-alpha01

July 2, 2019

androidx.fragment:fragment:1.2.0-alpha01, androidx.fragment:fragment-ktx:1.2.0-alpha01, and androidx.fragment:fragment-testing:1.2.0-alpha01 are released. The commits included in this version can be found here.

New features

  • FragmentManager now calls requestApplyInsets() after attaching the Fragment’s view and directly before calling onViewCreated(), ensuring that your view always has the correct insets. (b/135945162)

Bug fixes

  • Fixed a NullPointerException when popping a FragmentTransaction that used setPrimaryNavigationFragment() before replace(). (b/134673465)

Version 1.1.0

Version 1.1.0

September 5, 2019

androidx.fragment:fragment:1.1.0, androidx.fragment:fragment-ktx:1.1.0, and androidx.fragment:fragment-testing:1.1.0 are released. The commits included in this version can be found here.

Important Changes since 1.0.0

  • fragment-testing: The fragment-testing artifact provides a FragmentScenario class for testing a fragment in isolation. See Test your app’s fragments documentation for more details.
  • FragmentFactory: You can now set a FragmentFactory on a FragmentManager to manage the creation of fragment instances, removing the strict requirement to have a no-argument constructor.
  • Kotlin Property Delegates for ViewModels: The fragment-ktx artifact now contains two Kotlin property delegates: by viewModels() for accessing ViewModels associated with the individual fragment and by activityViewModels() for accessing ViewModels scoped to the activity.
  • Max Lifecycle: You can now set a max Lifecycle state for a Fragment by calling setMaxLifecycle() on a FragmentTransaction. This replaces the now deprecated setUserVisibleHint(). FragmentPagerAdapter and FragmentStatePagerAdapter have a new constructor that allows you to switch to the new behavior.
  • FragmentActivity LayoutId constructor: Subclasses of FragmentActivity can now optionally call into a constructor on FragmentActivity that takes an R.layout ID, indicating the layout that should be set as the content view as an alternative to calling setContentView() in onCreate(). This does not change the requirement that your subclass have a no-argument constructor.
  • Fragment LayoutId constructor: Subclasses of Fragment can now optionally call into a constructor on Fragment that takes an R.layout ID, indicating the layout that should be used for this fragment as an alternative to overriding onCreateView(). The inflated layout can be configured in onViewCreated().
  • Postpone with a timeout: A new overload of postponeEnterTransition() has been added that takes a timeout.

Version 1.1.0-rc04

August 7, 2019

androidx.fragment:fragment:1.1.0-rc04, androidx.fragment:fragment-ktx:1.1.0-rc04, and androidx.fragment:fragment-testing:1.1.0-rc04 is released. The commits included in this version can be found here.

Bug fixes

  • Fragments now correctly cancel postponed transitions on Fragments have been popped. (b/138251858)

Version 1.1.0-rc03

July 19, 2019

androidx.fragment:fragment:1.1.0-rc03, androidx.fragment:fragment-ktx:1.1.0-rc03, and androidx.fragment:fragment-testing:1.1.0-rc03 is released. The commits included in this version can be found here.

Bug fixes

  • Fixed an issue where calling postponeEnterTransition() with a timeout more than once would not cancel previous timeouts. (b/137797118)

Version 1.1.0-rc02

July 17, 2019

androidx.fragment:fragment:1.1.0-rc02, androidx.fragment:fragment-ktx:1.1.0-rc02, and androidx.fragment-testing:fragment:1.1.0-rc02 are released. The commits included in this version can be found here.

Bug fixes

  • Fixed a crash in FragmentPagerAdapter and FragmentStatePagerAdapter when removing the current item. (b/137209870)

Version 1.1.0-rc01

July 2, 2019

androidx.fragment:fragment:1.1.0-rc01, androidx.fragment:fragment-ktx:1.1.0-rc01, and androidx.fragment:fragment-testing:1.1.0-rc01 are released. The commits included in this version can be found here.

Bug fixes

  • Fragments now properly update their visibility when using show() or hide() operations while the transition is running. (b/133385058)
  • Fixed a NullPointerException when popping a FragmentTransaction that used setPrimaryNavigationFragment() before replace(). (b/134673465)

Version 1.1.0-beta01

June 5, 2019

androidx.fragment:fragment:1.1.0-beta01, androidx.fragment:fragment-ktx:1.1.0-beta01, and androidx.fragment:fragment-testing:1.1.0-beta01 are released. The commits included in this version can be found here.

Bug fixes

  • androidx.lifecycle.Lifecycle callbacks (specifically related to STARTED, RESUMED, PAUSED, STOPPED, and DESTROYED) for nested Fragments are now properly nested. (b/133497591)
  • OnBackPressedCallback instances registered in a Fragment’s onCreate() now properly take precedence over the child FragmentManager. (b/133175997)
  • Child fragments are no longer animated when their parent fragment is being replaced. (b/121017790)
  • Fragments animations and transitions are now ignored when using animateLayoutChanges="true", fixing an issue where Fragments were not properly destroyed. (b/116257087)

Version 1.1.0-alpha09

May 16, 2019

androidx.fragment:fragment:1.1.0-alpha09, androidx.fragment:fragment-ktx:1.1.0-alpha09, and androidx.fragment:fragment-testing:1.1.0-alpha09 are released. The commits included in this version can be found here.

API changes

  • Fragments now receive a callback to a new onPrimaryNavigationFragmentChanged(boolean) method when the primary navigation fragment changes. aosp/960857

Bug fixes

  • Menu Items inflated by a child Fragment are now correctly removed when the Parent Fragment is removed. b/131581013

Version 1.1.0-alpha08

May 7, 2019

androidx.fragment:fragment:1.1.0-alpha08, androidx.fragment:fragment-ktx:1.1.0-alpha08, and androidx.fragment:fragment-testing:1.1.0-alpha08 are released. The commits included in this version can be found here.

This release is incompatible with Preferences 1.1.0-alpha01 through 1.1.0-alpha04. Please upgrade to Preferences 1.1.0-alpha05 when using this version of Fragments.

New features

  • Added a new overload of postponeEnterTransition() that takes a timeout, after which the Fragment will automatically call startPostponedEnterTransition() b/120803208

API changes

  • Breaking change: the previously deprecated FragmentFactory instantiate method that took a Bundle has been removed. aosp/953856
  • Breaking change: The RESUME_ONLY_CURRENT_FRAGMENT and USE_SET_USER_VISIBLE_HINT constants in FragmentPagerAdapter and FragmentStatePagerAdapter have been renamed to BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT and BEHAVIOR_SET_USER_VISIBLE_HINT, respectively. aosp/954782

Bug fixes

  • Fragments that have had their lifecycle capped via setMaxLifecycle() no longer get resumed before reaching their final state. b/131557151
  • When using setMaxLifecycle(Lifecycle.State.CREATED), Fragments will properly have their view destroyed. aosp/954180

Version 1.1.0-alpha07

April 25, 2019

androidx.fragment:fragment:1.1.0-alpha07, androidx.fragment:fragment-ktx:1.1.0-alpha07, and androidx.fragment:fragment-testing:1.1.0-alpha07 are released. The commits included in this version can be found here.

New features

  • You can now set a max Lifecycle state for a Fragment by calling setMaxLifecycle() on a FragmentTransaction. This replaces the now deprecated setUserVisibleHint(). FragmentPagerAdapter and FragmentStatePagerAdapter have a new constructor that allows you to switch to the new behavior. (b/129780800)

API Changes

  • moveToState(STARTED) on FragmentScenario can now only be called on API 24+ devices. (b/129880016)

Behavior Changes

  • As a consequence of (b/129907905), fragments on the back stack will not get a callback to onCreateView() when the hosting activity is recreated. onCreateView() will now only be called when the fragment becomes visible (i.e., the back stack is popped).

Bug fixes

  • Fixed an issue when using a <fragment> tag in XML and the contentLayoutId constructor of FragmentActivity or AppCompatActivity. (b/129907905)
  • Corrected an issue where fragments on the back stack would not be moved to at least CREATED after a configuration change, causing ViewModels and child retained fragments to not be properly disposed. (b/129593351)
  • Fixed a crash in restoreSaveState caused by a desync of the retained fragments after the instance state is saved. (b/130433793) (aosp/947824)
  • Fixed issues where an OnBackPressedCallback added with a fragment lifecycle would not be called if the FragmentManager had a back stack. See androidx.activity 1.0.0-alpha07 for more details. (aosp/948209)
  • Fragments no longer enforce LAYER_TYPE_HARDWARE for animations. If you specifically need a hardware layer animation, please set it as part of your animation. (b/129486478)

Version 1.1.0-alpha06

April 3, 2019

androidx.fragment:fragment:1.1.0-alpha06, androidx.fragment:fragment-ktx:1.1.0-alpha06, and androidx.fragment:fragment-testing:1.1.0-alpha06 are released. The commits included in this version can be found here.

New features

  • Exceptions thrown by FragmentManager now include the Fragment’s name in the message. (b/67759402)

API Changes

  • Fragment and FragmentActivity now contain a second constructor that takes a @LayoutRes int, which replaces the previous behavior of annotating your class with @ContentView. This approach works in both app and library modules. (b/128352521)
  • FragmentActivity’s onActivityResult() is now properly marked as @CallSuper. (b/127971684)
  • The FragmentFactory’s instantiate method that takes an argument Bundle has been deprecated and apps should use the new instantiate overload that does not take a Bundle. (b/128836103)
  • FragmentScenario methods are now properly annotated with @StyleRes. (aosp/924193)
  • FragmentTabHost has been deprecated. (b/127971835)
  • FragmentActivity’s getThemedContext() has been removed. (aosp/934078)

Bug fixes

  • Fixed a regression in 1.1.0-alpha05 that caused the incoming Fragment to flash on the screen. (b/129405432)
  • Fixed an issue where the primary navigation fragment would be lost after a popBackStack+replace+popBackStack series of operations. (b/124332597)
  • Fixed an issue when using @ContentView constructors on your Activity when restoring Fragment state. (b/127313094)
  • Corrected the logic of setTargetFragment() when replacing an existing target Fragment with a Fragment not yet attached to the FragmentManager. (aosp/932156)

Version 1.1.0-alpha05

March 13, 2019

androidx.fragment:fragment:1.1.0-alpha05, androidx.fragment:fragment-ktx:1.1.0-alpha05, and androidx.fragment:fragment-testing:1.1.0-alpha05 are released. The full list of commits included in this version can be found here.

New features

  • @ContentView annotation lookups are now cached (b/123709449)

Behavior changes

  • Calling remove(), hide(), show(), detach(), and setPrimaryNavigationFragment() with a Fragment attached to a different FragmentManager now throws an IllegalStateException rather than silently failing (aosp/904301)

Bug fixes

  • onNewIntent for FragmentActivity is now correctly marked with @CallSuper (b/124120586)
  • Fixed an issue where DialogFragment’s onDismiss() could be called twice when using getDialog().dismiss() or getDialog().cancel() (b/126563750)

Version 1.1.0-alpha04

February 7, 2019

androidx.fragment:fragment 1.1.0-alpha04, androidx.fragment:fragment-ktx 1.1.0-alpha04, and androidx.fragment:fragment-testing 1.1.0-alpha04 are released.

New features

  • Added support for the @ContentView class annotation that allows you to indicate which layout XML file should be inflated as an alternative to overriding onCreateView(). It is recommended to do view related work in onViewCreated(). (aosp/837619)
  • fragment-testing now depends on androidx.test:core-ktx 1.1.0 stable (b/121209673)
  • You can now use openActionBarOverflowOrOptionsMenu with FragmentScenario to test Fragment hosted options menus (b/121126668)

API changes

  • Added a requireArguments() method which returns a @NonNull Bundle or throws an IllegalStateException (b/121196360)
  • Added a note that getLifecycle(), getViewLifecycleOwner(), and getViewLifecycleOwnerLiveData() should not be overridden and will be made final in a future release. Please file a feature request if you are currently overriding this method. (aosp/880714)
  • Added a note that getViewModelStore() should not be overridden and will be made final in a future release. Please file a feature request if you are currently overriding this method. (aosp/880713)
  • Fixed an issue with binary compatibility with previous releases of Fragments. (aosp/887877) (aosp/889834)

Bug fixes

  • Target fragments are correctly cleared out when you pass null to setTargetFragment(). (aosp/849969)
  • Fixed an issue where target Fragments were sometimes unavailable in or after onDestroy(). (b/122312935)
  • DialogFragment’s onDismiss() is now called before onDestroy(). (aosp/874133) (aosp/890734)

Version 1.1.0-alpha03

December 17, 2018

New features

  • Fragment now implements BundleSavedStateRegistryOwner and depends on the newly released SavedState library [aosp/824380]
  • A by activityViewModels Kotlin property delegate has been added to retrieve ViewModels associated with the containing Activity [b/119050253]
  • The by viewModels Kotlin property delegate has been expanded to take an optional lambda method for getting the ViewModelStoreOwner, allowing you to pass in the parent Fragment or other custom ViewModelStoreOwner with code such as val viewModel: MyViewModel by viewModels(::requireParentFragment) [b/119050253]

API changes

  • FragmentScenario now allows you to specify a theme such as Theme.AppCompat [b/119054431]. This is a breaking change.
  • Added a requireView() method which returns a @NonNull View or throws an IllegalStateException [b/120241368]
  • Added a requireParentFragment() method which returns a @NonNull Fragment or throws an IllegalStateException [b/112103783]

Bug fixes

  • Fixed IllegalStateException: Failure saving state b/120814739
  • Fragments being restored from saved instance state will now always receive a non-null Bundle [b/119794496]
  • Removed Fragments no longer reuse their Lifecycle object if re-added [b/118880674]

Version 1.1.0-alpha02

December 3, 2018

New features

  • FragmentScenario’s Kotlin extensions now let you use a lambda for Fragment construction as an alternative to passing in a FragmentFactory instance. (aosp/812913)

Bug fixes

  • Fixed an IllegalStateException when using nested Fragments on the back stack (b/119256498)
  • Fixed crash when using FragmentScenario.recreate() with a FragmentFactory (aosp/820540)
  • Fixed an issue where target Fragments were not accessible after the Fragment was removed (aosp/807634)

Version 1.1.0-alpha01

November 5, 2018

This is the first release of the fragment-testing artifact and FragmentScenario which is built on top of the androidx.test:core APIs. See the Fragment testing documentation for more details.

New features

  • New FragmentScenario class for testing Fragments in isolation.
  • You can now set a FragmentFactory on any FragmentManager to control how new Fragment instances are instantiated.
  • Added a new by viewModels() Kotlin property delegate for retrieving ViewModels from a Fragment.
  • Pending input events (such as clicks) are now canceled in a Fragment’s onStop().

API changes

  • Significantly expanded the nullability annotations across the Fragment API surface.

Bug fixes

  • Fix an issue which caused Fragment operations to fail from within LiveData (b/77944637)

Known issues

  • Target Fragments cannot be accessed after a Fragment has been removed from the FragmentManager.
  • fragment-testing depends on androidx.test:core:1.0.0-beta01 instead of the correct androidx.test:core:1.0.0.