Android navigation and activities in separate dynamic features

182 views Asked by At

It looks like for reasons difficult to understand in my android app that supports Navigation and Dynamic Features, when I navigate from an activity declared in the base app to an activity inside a separate Dynamic Features with a different navigation drawer the app loads the destination activity and its fragment but they stay invisible on top of the origin's fragment, infact I can click on the position of the EditTexts that I know are present in the destination fragment and the virtual keyboard is displayed even if the control is invisible. It was working before, now don't. When I click on a navigation drawer menu's item in Logcat appears the following non blocking exception:

system_process E/WindowManager: Unhandled exception while laying out windows java.lang.RuntimeException: Unknown animation name: objectAnimator at android.view.animation.AnimationUtils.createAnimationFromXml(AnimationUtils.java:192) at android.view.animation.AnimationUtils.createAnimationFromXml(AnimationUtils.java:157) at android.view.animation.AnimationUtils.loadAnimation(AnimationUtils.java:138) at com.android.server.wm.AppTransition.loadAnimationRes(AppTransition.java:574) at com.android.server.wm.AppTransition.loadAnimation(AppTransition.java:1593) at com.android.server.wm.AppWindowToken.loadAnimation(AppWindowToken.java:1838) at com.android.server.wm.AppWindowToken.applyAnimationLocked(AppWindowToken.java:1756) at com.android.server.wm.AppWindowToken.setVisibility(AppWindowToken.java:412) .....

that anyway is not causing the app to fail. If I bring the app to the background and then back to the foreground the destination activity appears and works properly. From what I can understand it looks like the transition animation is not completed, but I don't know where to check if there is something wrong with the default animation Android is using to display the destination activity's fragment. If I remove the destination activity and I force the app to navigate to a fragment in the other Dynamic Feature (keeping the activity of the base app instead of creating a new one in the Dynamic Feature) it works fine. So something is wrong with the transition animations and the activity in the destination Dynamic Feature. Is there a way to check the animations to make sure they are executed properly ? Please help, it's days now I'm trying to fix this.

1

There are 1 answers

0
Sergio B. On

The problem wasn't actually due to a bug of mine. Today Google ha released version 2.3.2 of

androidx.navigation:navigation-fragment-ktx
androidx.navigation:navigation-ui-ktx

And that fixes the problem. So beware, version 2.3.1 has a very subtle bug, described in my post.

Navigation Version 2.3.2 December 2, 2020

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

Bug Fixes

Fixed a regression in NavigationUI where using an destination with onNavDestinationSelected would fail to navigate to the Activity. (I22e34, b/171364502) Fixed an issue where navigation-dynamic-features-fragment would result in navigating to the newly installed destination multiple times. (aosp/1486056, b/169636207) Fixed an issue where default arguments would not be sent to OnDestinationChangedListener instances when using launchSingleTop. (I2c5cb) Fixed an issue where navigating to a nested navigation graph would not create a new graph instance on the back stack. (Ifc831) Fixed an issue where using navigate() with a popUpTo that removed the last destination in a navigation graph would not immediately destroy and remove the navigation graph itself from the back stack. (I910a3) Navigation SafeArgs now uses KotlinPoet version 1.7.2 which adds support for Kotlin's explicit API mode. (I918b5) NavHostFragment.findNavController(Fragment) now also checks the root decor view of a DialogFragment in addition to the existing checks of the Fragment hierarchy and Fragment's view hierarchy. This allows you to test dialog fragments that use Navigation with FragmentScenario and Navigation.setViewNavController(). (I69e0d)