Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit e1b42da3ee5bcb06756d8cb8377abf6116086e11
Author: Sanura N'Jaka <sanura@google.com>
Date: Tue Sep 07 20:23:52 2021
Make nullable NavDeepLink arguments not required
Removing the inclusion of nullable NavDeepLink
arguments from the "required" argument checking.
RelNote: "Nullable `NavDeepLink` arguments no longer
require a default value."
Test: deepLinkNullableArgumentNotRequired test
Bug: 198689811
Change-Id: Ia14ef04bfe5b25942163688f40adacc30fa7e044
M navigation/navigation-common/src/androidTest/java/androidx/navigation/AddInDefaultArgsTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/test/NavArgument.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDeepLink.kt
https://android-review.googlesource.com/1817360
Branch: androidx-main
commit e1b42da3ee5bcb06756d8cb8377abf6116086e11
Author: Sanura N'Jaka <sanura@google.com>
Date: Tue Sep 07 20:23:52 2021
Make nullable NavDeepLink arguments not required
Removing the inclusion of nullable NavDeepLink
arguments from the "required" argument checking.
RelNote: "Nullable `NavDeepLink` arguments no longer
require a default value."
Test: deepLinkNullableArgumentNotRequired test
Bug: 198689811
Change-Id: Ia14ef04bfe5b25942163688f40adacc30fa7e044
M navigation/navigation-common/src/androidTest/java/androidx/navigation/AddInDefaultArgsTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/NavDeepLinkTest.kt
M navigation/navigation-common/src/androidTest/java/androidx/navigation/test/NavArgument.kt
M navigation/navigation-common/src/main/java/androidx/navigation/NavDeepLink.kt
jb...@google.com <jb...@google.com>
ap...@google.com <ap...@google.com> #3
There's two issues here:
android:defaultValue="@null"
is actually treated as thedefaultValue
attribute not existing at all at runtime (we do still use it for Safe Args)- We enforced every argument without a default value to be present in the URI/route, even if it was nullable.
While we can't fix the first one, we have made the change in Navigation 2.4.0-alpha09
to only check for default values for non-nullable parameters. This should mean that
- Using
android:defaultValue="@null"
won't be a problem - Constructing a type in the Kotlin DSL via
navArgument("argument_name")
and making itnullable = true
without a default value won't be a problem.
il...@google.com <il...@google.com> #4
Unfortunately I still experience this bug with 2.4.0-alpha09 :(
java.lang.IllegalArgumentException: Deep link penny://app/offers can't be used to open destination Destination(de.penny.app.debug:id/offerListFragment) label=OfferListFragment class=de.penny.feature.offer.view.OfferListFragment.
Following required arguments are missing: [sectionIndexOrName, raffleId]
This is the excerpt from my navigation graph XML:
<argument
android:name="sectionIndexOrName"
android:defaultValue="@null"
app:argType="string"
app:nullable="true" />
<argument
android:name="raffleId"
android:defaultValue="@null"
app:argType="string"
app:nullable="true" />
<deepLink
android:id="@+id/offersDeeplink"
app:uri="penny://app/offers" />
As you can see both parameters are nullable and have a default value of null
.
Description
Version used: 2.1.0-alpha03
Devices/Android versions reproduced on:
If you repeat Navigate with URI, the back key does not work.
I'll attach the sample project. Please check below how to reproduction.
1. Tap `MOVE TO A`
2. Tap `MOVE TO B`
3. Tap `MOVE TO D` (Navigate with URI to another nav graph)
4. Press back key.
5. Repeat step 3 and step 4 2 times
6. We can't back to Fragment A.
I think mBackStack is not correct in NavGraphNavigator and NavController.
When step3, NavGraphNavigator#navigate is not called, but NavGraph is added to NavController.mBackStack.
Thanks.