androidmauiillegalargumentexceptiontabbedpage

C# MAUI app - Java.Lang.IllegalArgumentException: No view found for id 0x7f080147 on Android


I have created a sample C# project to demonstrate what I want to achieve. Here, you can check it: GiHub sample

In the example, when I press the button on MainPage, I encounter the following error in Visual Studio Community 2022 (64 bit) - Current Version 17.8.5 on Android Emulator - Pixel 5.

Java.Lang.IllegalArgumentException Message=No view found for id 0x7f080147 (com.companyname.tabbedpagetestapp:id/navigationlayout_toptabs) for fragment ViewFragment{4ddc8ef} (1c250268-2232-41b3-8c18-cb3a65799ebc id=0x7f080147)

On Windows it's a bit buggy, but works (sometimes).

Any help would be appreciated.


Solution

  • You can find this tip in the doc TabbedPage:

    Warning

    TabbedPage is incompatible with .NET MAUI Shell apps, and an exception will be thrown if you attempt to use TabbedPage in a Shell app.

    In other words, TabbedPage cannot be used together with Shell. Otherwise it will cause an error.

    You can also see the official sample App.xaml.cs file, which looks like this:

    public partial class App : Application
    {
        public App()
        {
            InitializeComponent();
    
            MainPage = new AppTabbedPage();
        }
    }
    

    instead of:

    public partial class App : Application
    {
        public App()
        {
            InitializeComponent();
    
            MainPage = new AppShell();
        }
    }