Skip to content

The app crashes with SimpleShell #35

@ziomek64

Description

@ziomek64

Hello,
I've just stumbled upon your SimpleToolkit and I wanted to implement it. It looks awesome, has some stuff that I need and also Material3 TabBar in Controls.

Right now I'm getting unhandled exception:
Java.Lang.IllegalArgumentException: 'No view found for id 0x5 (unknown) for fragment SimpleFragment{acb1dc6} (0b7617ee-9aaa-4da3-88ab-d0e65a35f48c id=0x5)'

I'm trying to follow the guide to have basic implementation for starters and I swapped everything for SimpleShell. So I'm gonna give you a tour over it.
MauiProgram.cs

using MauiApp2.Views;
using MauiApp2.ViewModels;
using Microsoft.Extensions.Logging;
using CommunityToolkit.Maui;
using Material.Components.Maui.Extensions;
using Material.Components.Maui;
using SimpleToolkit.Core;
using SimpleToolkit.SimpleShell;

namespace MauiApp2;

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>()
            .UseMauiCommunityToolkit()
            //TODO .UseMaterialComponents()
            .UseSimpleShell()



            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
            });


#if DEBUG
        builder.Logging.AddDebug();
#endif
        return builder.Build();
    }
}

App.xaml.cs

namespace MauiApp2;

public partial class App : Application
{
    public App()
    {
        InitializeComponent();

        MainPage = new AppShell();
    }
}

AppShell.xaml. I have login page route and the main one with tab bar.

<?xml version="1.0" encoding="UTF-8" ?>
<simpleShell:SimpleShell
    x:Class="MauiApp2.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:DetailsViews="clr-namespace:MauiApp2.Views.DetailsViews"
    xmlns:Views="clr-namespace:MauiApp2.Views"
    xmlns:local="clr-namespace:MauiApp2"
    xmlns:simpleShell="clr-namespace:SimpleToolkit.SimpleShell;assembly=SimpleToolkit.SimpleShell"
    Shell.FlyoutBehavior="Disabled">





    <ShellItem FlyoutItemIsVisible="False" Route="LandingPage">
        <ShellContent ContentTemplate="{DataTemplate Views:LandingPage}" />
    </ShellItem>

    <TabBar Route="main">
        <Tab Title="Home" Icon="home.png">
            <ShellContent ContentTemplate="{DataTemplate Views:HomePage}" />
        </Tab>
        <Tab Title="Profile" Icon="user.png">
            <ShellContent ContentTemplate="{DataTemplate Views:ProfilePage}" />
        </Tab>
        <Tab Title="Anime" Icon="play_anime.png">
            <ShellContent ContentTemplate="{DataTemplate Views:AnimeListPage}" />
        </Tab>
        <Tab Title="Manga" Icon="read_manga.png">
            <ShellContent ContentTemplate="{DataTemplate Views:MangaListPage}" />
        </Tab>
        <Tab Title="Settings" Icon="settings.png">
            <ShellContent ContentTemplate="{DataTemplate Views:SettingsPage}" />
        </Tab>
    </TabBar>

</simpleShell:SimpleShell>
using MauiApp2.Views;
using MauiApp2.Views.DetailsViews;
using SimpleToolkit.SimpleShell;

namespace MauiApp2;

public partial class AppShell : SimpleToolkit.SimpleShell.SimpleShell
{
    public AppShell()
    {
        Routing.RegisterRoute("MediaDetailsPage", typeof(MediaDetailsPage));
        Routing.RegisterRoute("MediaCharacterListPage", typeof(MediaCharacterListPage));
        Routing.RegisterRoute("MediaStaffListPage", typeof(MediaStaffListPage));
        InitializeComponent();
    }
}

When I'm loading the app on that login page, it checks for token on apperance etc and goes to main route. I'm pointing this out now that I've also tried with just Shell

            if (validation)
            {
                await SimpleToolkit.SimpleShell.SimpleShell.Current.GoToAsync($"//main");
            }

This is the only Shell and navigation stuff that happens and I'm crashing. When I'm swapping everything back to Shell it will load my app. So I've need some help, because maybe I'm missing something. Are all toolkit nugets supposed to be installed on platform specific projects too? Because I didn't get an option to do so. Just the main one. Which might be the problem..

From my main project file:

<Project Sdk="Microsoft.NET.Sdk">

	<PropertyGroup>
		<TargetFrameworks>net8.0-android</TargetFrameworks>

I don't have 34 after android like in nuget requirements. But yeah it's targetting 34. I don't have 34 because the app just wouldn't start with numbera after android, after .net 8 upgrade.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions