Status Update
Comments
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #2
Now, instead of crashing, we ignore invalid deep links, printing a log message saying as much.
il...@google.com <il...@google.com> #3
The problem still occurs on version 2.2.0-rc04
ap...@google.com <ap...@google.com> #4
ap...@google.com <ap...@google.com> #5
ap...@google.com <ap...@google.com> #6
ap...@google.com <ap...@google.com> #7
ap...@google.com <ap...@google.com> #8
NavDestination node = i == 0 ? mGraph : graph.findNode(destinationId);
if deepLink.length == 1 node never will be null and this will cause IllegalStateException
Bug demo:
get NavigationAdvancedSample from github
on R.id.about_btn click
NavDeepLinkBuilder(it.context)
.setGraph(R.navigation.list)
.setDestination(R.id.leaderboard)
.createTaskStackBuilder()
.startActivities()
will crash because R.id.leaderboard is start destination (findInvalidDestinationDisplayNameInDeepLink will have deepLink length == 1)
NavDeepLinkBuilder(it.context)
.setGraph(R.navigation.list)
.setDestination(R.id.userProfile)
.createTaskStackBuilder()
.startActivities()
will work because findInvalidDestinationDisplayNameInDeepLink will return NOT null
ap...@google.com <ap...@google.com> #9
It still crash with the latest version 2.2.1. I think the problem lies somewhere around this code
NavDestination node = i == 0 ? mGraph : graph.findNode(destinationId);
When i
is 0
, just return mGraph
itself. When the deep link destination is a root of bottom_nav tab, the deeplink.length
becomes 1. Which means this function still says there's no invalid Destination in deep link even if deepLink[0]
is totally irrelevant tomGraph
.
So this step passes and when findDestination() is actually triggered down the road, it won't find any destination and thus lead to unknown destination
crash.
All NavControllers of bottom nav automatically call handleDeepLink()
as part of onGraphCreated()
. The problem arises the moment NavController whose graph is irrelevant to the root deep link destination calls handleDeepLink()
.
ap...@google.com <ap...@google.com> #10
It still crashes with 2.3.0-alpha03 version but only if you try to deeplink to startDestination fragment inside navigation graph. Repro steps (described in #8, but lets repeat it in hope issue will be reopened):
- download NavigationAdvancedSample
- send pending intent to any startDestination screen, e.g.
val pendingIntent = NavDeepLinkBuilder(applicationContext)
.setGraph(R.navigation.list)
.setDestination(R.id.leaderboard)
.setArguments(bundle) // no matter if it is empty in this use case
.createPendingIntent()
pendingIntent.send()
Exception:
Caused by: java.lang.IllegalStateException: unknown destination during deep link: com.example.android.navigationadvancedsample:id/list
at androidx.navigation.NavController.handleDeepLink(NavController.java:689)
at androidx.navigation.NavController.onGraphCreated(NavController.java:602)
at androidx.navigation.NavController.setGraph(NavController.java:563)
at androidx.navigation.NavController.setGraph(NavController.java:528)
at androidx.navigation.fragment.NavHostFragment.onCreate(NavHostFragment.java:246)
at androidx.fragment.app.Fragment.performCreate(Fragment.java:2684)
at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:280)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1175)
at androidx.fragment.app.FragmentTransition.addToFirstInLastOut(FragmentTransition.java:1255)
at androidx.fragment.app.FragmentTransition.calculateFragments(FragmentTransition.java:1138)
at androidx.fragment.app.FragmentTransition.startTransitions(FragmentTransition.java:136)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1989)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1947)
at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1818)
at androidx.fragment.app.BackStackRecord.commitNow(BackStackRecord.java:297)
at com.example.android.navigationadvancedsample.NavigationExtensionsKt.obtainNavHostFragment(NavigationExtensions.kt:269)
at com.example.android.navigationadvancedsample.NavigationExtensionsKt.setupWithNavController(NavigationExtensions.kt:61)
at com.example.android.navigationadvancedsample.MainActivity.setupBottomNavigationBar(MainActivity.kt:121)
at com.example.android.navigationadvancedsample.MainActivity.onCreate(MainActivity.kt:54)
Reopening would be a good sign that issue is recognized.
ap...@google.com <ap...@google.com> #11
Just in a case Reopen feature is not implemented in IssueTracker :), new ticket is created:
ap...@google.com <ap...@google.com> #12
an...@google.com <an...@google.com> #13
an...@google.com <an...@google.com> #14
Filing a new bug with a sample project that reproduces the issue you're still seeing is indeed the correct behavior. We don't support bug necromancy, particularly 30 releases after the original fix was shipped.
ap...@google.com <ap...@google.com> #15
Branch: androidx-master-dev
commit c403da82b263cf8078bacafb9f4661e279a3089c
Author: Ian Lake <ilake@google.com>
Date: Tue Oct 06 13:24:40 2020
Update navigation-ui to depend on DrawerLayout 1.1.1
DrawerLayout 1.1.1 includes a fix to the open()
call used by NavigationUI when locking the drawer.
Test: tested as part of
Relnote: "`navigation-ui` now depends on
[DrawerLayout 1.1.1](/jetpack/androidx/releases/drawerlayout#1.1.1),
ensuring that `NavigationUI` is able to open the drawer
even when using `LOCK_MODE_LOCKED_CLOSED` or
`LOCK_MODE_LOCKED_OPEN`."
Change-Id: Ie2eeec35770138e9d69396c0eea3c1a45e7d757b
M navigation/navigation-ui/build.gradle
an...@google.com <an...@google.com> #16
The following changes were cherrypicked through
Release Track:
Changes: aosp/1451099
Description
Component used: DrawerLayout Version used: 1.1.0
When attempting to use the
Openable
APIs ofopen()
andclose()
, they do not work if you are usingLOCK_MODE_LOCKED_CLOSED
. As per its documentation:So programmatically opening/closing the drawer should be allowed. This would make it consistent with
openDrawer()
andcloseDrawer()
.