简体   繁体   English

Android 导航和活动中单独的动态功能

[英]Android navigation and activities in separate dynamic features

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.在我的支持导航和动态功能的 android 应用程序中,当我从基本应用程序中声明的活动导航到具有不同导航抽屉的单独动态功能内的活动时,似乎由于难以理解的原因,应用程序加载目标活动和它的片段,但它们在源片段的顶部保持不可见,事实上我可以单击我知道存在于目标片段中的 EditTexts 的 position,即使控件不可见,也会显示虚拟键盘。 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:当我单击 Logcat 中的导航抽屉菜单项时,会出现以下非阻塞异常:

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.loadA 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.loadA nimation(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)..... nimation(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.据我了解,看起来过渡 animation 尚未完成,但我不知道在哪里检查默认 animation Android 是否有问题用于显示目标活动片段。 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.请帮忙,现在我正在尝试解决这个问题。

The problem wasn't actually due to a bug of mine.这个问题实际上不是由于我的错误。 Today Google ha released version 2.3.2 of今天谷歌发布了2.3.2版本

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 .所以要小心,2.3.1 版有一个非常微妙的错误,在我的帖子中有描述

Navigation Version 2.3.2 December 2, 2020导航版本 2.3.2 2020 年 12 月 2 日

androidx.navigation:navigation-*:2.3.2 is released. androidx.navigation:navigation-*:2.3.2 已发布。 Version 2.3.2 contains these commits.版本 2.3.2 包含这些提交。

Bug Fixes Bug修复

Fixed a regression in NavigationUI where using an destination with onNavDestinationSelected would fail to navigate to the Activity.修复了 NavigationUI 中的回归,其中使用带有 onNavDestinationSelected 的目的地将无法导航到 Activity。 (I22e34, b/171364502) Fixed an issue where navigation-dynamic-features-fragment would result in navigating to the newly installed destination multiple times. (I22e34, b/171364502) 修复了 navigation-dynamic-features-fragment 会导致多次导航到新安装的目的地的问题。 (aosp/1486056, b/169636207) Fixed an issue where default arguments would not be sent to OnDestinationChangedListener instances when using launchSingleTop. (aosp/1486056, b/169636207) 修复了使用 launchSingleTop 时默认 arguments 不会发送到 OnDestinationChangedListener 实例的问题。 (I2c5cb) Fixed an issue where navigating to a nested navigation graph would not create a new graph instance on the back stack. (I2c5cb) 修复了导航到嵌套导航图不会在后堆栈上创建新图实例的问题。 (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. (Ifc831) 修复了使用带有 popUpTo 的 navigate() 来删除导航图中的最后一个目的地的问题,该问题不会立即破坏导航图本身并将其从返回堆栈中删除。 (I910a3) Navigation SafeArgs now uses KotlinPoet version 1.7.2 which adds support for Kotlin's explicit API mode. (I910a3) Navigation SafeArgs 现在使用 KotlinPoet 版本 1.7.2,它增加了对 Kotlin 显式 API 模式的支持。 (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. (I918b5) NavHostFragment.findNavController(Fragment) 现在除了检查 Fragment 层次结构和 Fragment 的视图层次结构之外,还检查 DialogFragment 的根装饰视图。 This allows you to test dialog fragments that use Navigation with FragmentScenario and Navigation.setViewNavController().这允许您测试使用带有 FragmentScenario 和 Navigation.setViewNavController() 的导航的对话框片段。 (I69e0d) (I69e0d)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM