Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Shell, more than 5 tabs works until navigating to another tab bar and back. #22875

Closed
JRPMike opened this issue Jun 5, 2024 · 3 comments
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout area-controls-tabbedpage TabbedPage platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@JRPMike
Copy link

JRPMike commented Jun 5, 2024

Description

I have an application that uses the Shell flyout and two tabbars. Both tabbars have more than 5 tabs.

When I launch the application, it loads. I select an item to navigate to the first tabbar page. It works and the extra tabs are in the "more" item. I then navigate the the second tabbar page and it works as expected.

I then navigate back to the first and get:
Java.Lang.IllegalArgumentException: 'Maximum number of items supported by BottomNavigationView is 5. Limit can be checked with BottomNavigationView#getMaxItemCount()'
The app then crashes.

Steps to Reproduce

  1. Run the solution on Android emulator in debug.
  2. Click "Go To A"
  3. Click "Go To B"
  4. Click "Go To A"
  5. Should get the error and application crashes..

Link to public reproduction project repository

https://github.com/JRPMike/MauiTabsIssueReproduction.git

Version with bug

8.0.40 SR5

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

Android 14.0

Did you find any workaround?

No response

Relevant log output

**Java.Lang.IllegalArgumentException:** 'Maximum number of items supported by BottomNavigationView is 5. Limit can be checked with BottomNavigationView#getMaxItemCount()'

[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.IllegalArgumentException: Maximum number of items supported by BottomNavigationView is 5. Limit can be checked with BottomNavigationView#getMaxItemCount()
[mono-rt]    at Java.Interop.JniEnvironment.InstanceMethods.CallObjectMethod(JniObjectReference instance, JniMethodInfo method, JniArgumentValue* args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:line 19992
[mono-rt]    at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualObjectMethod(String encodedMember, IJavaPeerable self, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:line 867
[mono-rt]    at AndroidX.AppCompat.View.Menu.MenuBuilder.Add(Int32 group, Int32 id, Int32 categoryOrder, ICharSequence title) in C:\a\_work\1\s\generated\androidx.appcompat.appcompat\obj\Release
et6.0-android\generated\src\AndroidX.AppCompat.View.Menu.MenuBuilder.cs:line 810
[mono-rt]    at Android.Views.IMenuExtensions.Add(IMenu self, Int32 groupId, Int32 itemId, Int32 order, String title) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Android.Views.IMenu.cs:line 187
[mono-rt]    at Microsoft.Maui.Controls.Platform.BottomNavigationViewUtils.SetupMenu(IMenu menu, Int32 maxBottomItems, List`1 items, Int32 currentIndex, BottomNavigationView bottomView, IMauiContext mauiContext) in D:\a\_work\1\s\src\Controls\src\Core\Platform\Android\BottomNavigationViewUtils.cs:line 107
[mono-rt]    at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
[mono-rt]    at Android.App.SyncContext.<>c__DisplayClass2_0.<Post>b__0() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:line 36
[mono-rt]    at Java.Lang.Thread.RunnableImplementor.Run() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:line 36
[mono-rt]    at Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Java.Lang.IRunnable.cs:line 84
[mono-rt]    at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V callback, IntPtr jnienv, IntPtr klazz) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 22
[mono-rt]   --- End of managed Java.Lang.IllegalArgumentException stack trace ---
[mono-rt] java.lang.IllegalArgumentException: Maximum number of items supported by BottomNavigationView is 5. Limit can be checked with BottomNavigationView#getMaxItemCount()
[mono-rt] 	at com.google.android.material.navigation.NavigationBarMenu.addInternal(NavigationBarMenu.java:67)
[mono-rt] 	at androidx.appcompat.view.menu.MenuBuilder.add(MenuBuilder.java:478)
[mono-rt] 	at crc640ec207abc449b2ca.ShellItemRenderer.n_onCreateView(Native Method)
[mono-rt] 	at crc640ec207abc449b2ca.ShellItemRenderer.onCreateView(ShellItemRenderer.java:42)
[mono-rt] 	at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3114)
[mono-rt] 	at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:557)
[mono-rt] 	at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
[mono-rt] 	at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1943)
[mono-rt] 	at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1839)
[mono-rt] 	at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1782)
[mono-rt] 	at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:565)
[mono-rt] 	at android.os.Handler.handleCallback(Handler.java:958)
[mono-rt] 	at android.os.Handler.dispatchMessage(Handler.java:99)
[mono-rt] 	at android.os.Looper.loopOnce(Looper.java:205)
[mono-rt] 	at android.os.Looper.loop(Looper.java:294)
[mono-rt] 	at android.app.ActivityThread.main(ActivityThread.java:8177)
[mono-rt] 	at java.lang.reflect.Method.invoke(Native Method)
[mono-rt] 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
[mono-rt] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
[mono-rt]   --- End of managed Java.Lang.IllegalArgumentException stack trace ---
[mono-rt] java.lang.IllegalArgumentException: Maximum number of items supported by BottomNavigationView is 5. Limit can be checked with BottomNavigationView#getMaxItemCount()
[mono-rt] 	at com.google.android.material.navigation.NavigationBarMenu.addInternal(NavigationBarMenu.java:67)
[mono-rt] 	at androidx.appcompat.view.menu.MenuBuilder.add(MenuBuilder.java:478)
[mono-rt] 	at crc640ec207abc449b2ca.ShellItemRenderer.n_onCreateView(Native Method)
[mono-rt] 	at crc640ec207abc449b2ca.ShellItemRenderer.onCreateView(ShellItemRenderer.java:42)
[mono-rt] 	at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3114)
[mono-rt] 	at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:557)
[mono-rt] 	at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
[mono-rt] 	at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1943)
[mono-rt] 	at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1839)
[mono-rt] 	at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1782)
[mono-rt] 	at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:565)
[mono-rt] 	at android.os.Handler.handleCallback(Handler.java:958)
[mono-rt] 	at android.os.Handler.dispatchMessage(Handler.java:99)
[mono-rt] 	at android.os.Looper.loopOnce(Looper.java:205)
[mono-rt] 	at android.os.Looper.loop(Looper.java:294)
[mono-rt] 	at android.app.ActivityThread.main(ActivityThread.java:8177)
[mono-rt] 	at java.lang.reflect.Method.invoke(Native Method)
[mono-rt] 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
[mono-rt] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
[mono-rt]
@JRPMike JRPMike added the t/bug Something isn't working label Jun 5, 2024
Copy link
Contributor

github-actions bot commented Jun 5, 2024

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@PureWeen
Copy link
Member

PureWeen commented Jun 6, 2024

Can you test with the latest nightly build?
https://github.com/dotnet/maui/wiki/Nightly-Builds

@jsuarezruiz jsuarezruiz added the area-controls-shell Shell Navigation, Routes, Tabs, Flyout label Jun 6, 2024
@Zhanglirong-Winnie Zhanglirong-Winnie added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jun 6, 2024
@Zhanglirong-Winnie
Copy link

Verified this issue with Visual Studio 17.11.0 Preview 1.1 (8.0.40 ). Can repro on Android platform with sample project.
And not repro on latest nightly build & 8.0.60-ci.net8.24304.1.
image

@jsuarezruiz jsuarezruiz added this to the Backlog milestone Jun 6, 2024
@PureWeen PureWeen closed this as completed Jun 6, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout area-controls-tabbedpage TabbedPage platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants