Skip to content

Commit dfc9a20

Browse files
[android] update to the latest AndroidX packages (#5588)
* [android] update to the latest AndroidX packages Context: #5305 Fixes: dotnet/android-libraries#509 Update to the latest AndroidX packages, so we also use the latest Xamarin.Google.Guava.ListenableFuture This currently has build failures: src\Core\src\Platform\Android\Navigation\StackNavigationManager.cs(145,41): error CS1061: 'NavController' does not contain a definition for 'BackStack' and no accessible extension method 'BackStack' accepting a first argument of type 'NavController' could be found (are you missing a using directive or an assembly reference?) src\Core\src\Platform\Android\Navigation\StackNavigationManager.cs(188,48): error CS1061: 'NavController' does not contain a definition for 'BackStack' and no accessible extension method 'BackStack' accepting a first argument of type 'NavController' could be found (are you missing a using directive or an assembly reference?) src\Core\src\Platform\Android\Navigation\StackNavigationManager.cs(245,51): error CS1061: 'NavController' does not contain a definition for 'BackStack' and no accessible extension method 'BackStack' accepting a first argument of type 'NavController' could be found (are you missing a using directive or an assembly reference?) Looking at: ~\.nuget\packages\xamarin.androidx.navigation.runtime\2.4.1\lib\net6.0-android31.0\Xamarin.AndroidX.Navigation.Runtime.dll I can't find: [Register("androidx/navigation/NavController", DoNotGenerateAcw = true)] public class NavController : Object { public unsafe virtual IDeque BackStack { [Register("getBackStack", "()Ljava/util/Deque;", "GetGetBackStackHandler")] get; But it's not documented here either: https://developer.android.com/reference/androidx/navigation/NavController * - replace with BackQueue * - fix tests * $(NoWarn) XA4218 * $(MSBuildWarningsAsMessages) I mean Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
1 parent a333fc3 commit dfc9a20

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

eng/AndroidX.targets

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,55 @@
22
<ItemGroup>
33
<PackageReference
44
Update="Xamarin.AndroidX.AppCompat.AppCompatResources"
5-
Version="1.3.1.3"
5+
Version="1.4.1"
66
/>
77
<PackageReference
88
Update="Xamarin.AndroidX.Browser"
9-
Version="1.3.0.8"
9+
Version="1.4.0"
1010
/>
1111
<PackageReference
1212
Update="Xamarin.AndroidX.Legacy.Support.V4"
13-
Version="1.0.0.10"
13+
Version="1.0.0.12"
1414
/>
1515
<PackageReference
1616
Update="Xamarin.AndroidX.Lifecycle.LiveData"
17-
Version="2.3.1.3"
17+
Version="2.4.1"
1818
/>
1919
<PackageReference
2020
Update="Xamarin.AndroidX.Navigation.UI"
21-
Version="2.3.5.3"
21+
Version="2.4.1"
2222
/>
2323
<PackageReference
2424
Update="Xamarin.AndroidX.Navigation.Fragment"
25-
Version="2.3.5.3"
25+
Version="2.4.1.1"
2626
/>
2727
<PackageReference
2828
Update="Xamarin.AndroidX.Navigation.Runtime"
29-
Version="2.3.5.3"
29+
Version="2.4.1"
3030
/>
3131
<PackageReference
3232
Update="Xamarin.AndroidX.Navigation.Common"
33-
Version="2.3.5.3"
33+
Version="2.4.1"
3434
/>
3535
<PackageReference
3636
Update="Xamarin.AndroidX.MediaRouter"
37-
Version="1.2.5.2"
37+
Version="1.2.6"
3838
/>
3939
<PackageReference
4040
Update="Xamarin.AndroidX.Palette"
41-
Version="1.0.0.10"
41+
Version="1.0.0.12"
4242
/>
4343
<PackageReference
4444
Update="Xamarin.AndroidX.RecyclerView"
45-
Version="1.2.1.3"
45+
Version="1.2.1.5"
4646
/>
4747
<PackageReference
4848
Update="Xamarin.Build.Download"
49-
Version="0.10.0"
49+
Version="0.11.0"
5050
/>
5151
<PackageReference
5252
Update="Xamarin.Google.Android.Material"
53-
Version="1.4.0.4"
53+
Version="1.5.0.1"
5454
/>
5555
<PackageReference
5656
Update="Xamarin.AndroidX.Migration"

src/Core/src/Platform/Android/Navigation/StackNavigationManager.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using AndroidX.Navigation.Fragment;
1212
using AndroidX.Navigation.UI;
1313
using Google.Android.Material.AppBar;
14+
using Kotlin.Collections;
1415
using AToolbar = AndroidX.AppCompat.Widget.Toolbar;
1516
using AView = Android.Views.View;
1617

@@ -142,7 +143,7 @@ void ApplyNavigationRequest(NavigationRequest args)
142143

143144
IsAnimated = animated;
144145

145-
var iterator = NavHost.NavController.BackStack.Iterator();
146+
var iterator = NavHost.NavController.BackQueue.Iterator();
146147
var fragmentNavDestinations = new List<FragmentNavigator.Destination>();
147148

148149
while (iterator.HasNext)
@@ -185,7 +186,7 @@ void ApplyNavigationRequest(NavigationRequest args)
185186
// We only keep destinations around that are on the backstack
186187
// This iterates over the new backstack and removes any destinations
187188
// that are no longer apart of the back stack
188-
var iterateNewStack = NavHost.NavController.BackStack.Iterator();
189+
var iterateNewStack = NavHost.NavController.BackQueue.Iterator();
189190
int startId = -1;
190191
while (iterateNewStack.HasNext)
191192
{
@@ -242,7 +243,7 @@ List<int> Initialize(IReadOnlyList<IView> pages)
242243
var navController = NavHost.NavController;
243244

244245
// We are subtracting one because the navgraph itself is the first item on the stack
245-
int NativeNavigationStackCount = navController.BackStack.Size() - 1;
246+
int NativeNavigationStackCount = navController.BackQueue.Size() - 1;
246247

247248
// set this to one because when the graph is first attached to the controller
248249
// it will add the graph and the first destination

src/Core/tests/DeviceTests/Handlers/Navigation/NavigationViewHandlerTests.Android.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Microsoft.Maui.DeviceTests
1616
public partial class NavigationViewHandlerTests
1717
{
1818
int GetNativeNavigationStackCount(NavigationViewHandler navigationViewHandler) =>
19-
navigationViewHandler.StackNavigationManager.NavHost.NavController.BackStack.Size() - 1;
19+
navigationViewHandler.StackNavigationManager.NavHost.NavController.BackQueue.Size() - 1;
2020

2121
Task CreateNavigationViewHandlerAsync(IStackNavigationView navigationView, Func<NavigationViewHandler, Task> action)
2222
{

src/Workload/Microsoft.Maui.Sdk/Sdk/Microsoft.Maui.Sdk.After.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<EnableDefaultXamlItems Condition=" '$(EnableDefaultXamlItems)' == '' ">$(EnableDefaultMauiItems)</EnableDefaultXamlItems>
55
<EnableDefaultCssItems Condition=" '$(EnableDefaultCssItems)' == '' ">$(EnableDefaultMauiItems)</EnableDefaultCssItems>
66
<EnableDefaultEmbeddedResourceItems Condition=" '$(EnableDefaultEmbeddedResourceItems)' == '' ">$(EnableDefaultMauiItems)</EnableDefaultEmbeddedResourceItems>
7+
<!-- TODO: workaround https://github.com/xamarin/xamarin-android/issues/6809#issuecomment-1061115254 -->
8+
<MSBuildWarningsAsMessages Condition=" '$(TargetPlatformIdentifier)' == 'Android' ">$(MSBuildWarningsAsMessages);XA4218</MSBuildWarningsAsMessages>
79
</PropertyGroup>
810
<Import Project="Microsoft.Maui.Controls.targets" />
911
<Import Project="WinUI.targets" Condition=" '$(TargetPlatformIdentifier)' == 'windows' " />

0 commit comments

Comments
 (0)