Search code examples
androidandroid-architecture-navigation

Android Naviagtion navigateUp pop animation issue


I searched everywhere but i coudnt find a solution, heres the issue: [![enter image description here][1]][1]

the navigation graph/action

 <fragment
    android:id="@+id/einstellungenFragment"
    android:name="com.medbreaker.medat2go.EinstellungenFragment"
    android:label="fragment_einstellungen"
    tools:layout="@layout/fragment_einstellungen" >
    <action
        android:id="@+id/action_einstellungenFragment_to_aboutFragment"
        app:destination="@id/aboutFragment"
        app:enterAnim="@anim/slide_in_right"
        app:exitAnim="@anim/slidefadeout_left"
        app:popEnterAnim="@anim/slide_in_left"
        app:popExitAnim="@anim/slidefadeout_right"
        app:popUpTo="@+id/einstellungenFragment" />
</fragment>

everything is in a FragmentContainerView and in onBackPressed i'm just doing navController.navigateUp() (it is unreleated to back press, its the same if its triggered by a button)

MainActivity

val navHostFragment = supportFragmentManager.findFragmentById(R.id.main_navigation_host) as NavHostFragment
    navController = navHostFragment.navController
    NavigationUI.setupWithNavController(nav_view,navController)

these are the dependencys

def nav_version = "2.3.5"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

the strange thing is it did work at some point (released in play store), heres how its supposed to look like (i didnt change anyting really, except for updating dependencys maybe) [![enter image description here][2]][2]

Do you have any idea what could cause this issue?


Solution

  • As per the AppCompat 1.3.0-rc01 release notes, AppCompat now depends on Fragment 1.3.2.

    It is Fragments, not Navigation, that controls the animations between Fragments. Fragment 1.3.2 is affected by this issue where any pop animations are not being run, particularly in the use cases that Navigation uses.

    That issue is already fixed for an upcoming Fragment 1.3.3 release, but there's no workaround available when using Fragment 1.3.2. You can revert back to AppCompat 1.3.0-beta01 and manually include a dependency on Fragment 1.3.1 (and not 1.3.2), thus avoiding that issue:

    // Don't use AppCompat 1.3.0-rc01 since it depends on the broken Fragment 1.3.2
    def appcompat_version = "1.3.0-beta01"
    implementation "androidx.appcompat:appcompat:$appcompat_version"
    
    // Instead add an explicit dependency on Fragment 1.3.1, which is not affected
    def fragment_version = "1.3.1"
    implementation "androidx.fragment:fragment-ktx:$fragment_version"