0

I have the same issue as this thread

When I load my app on Windows Machine, NO ISSUE. However on Android I have an Exception pointing on the constructor of my TabbedPage

public partial class AppTabbedPage
{
    public AppTabbedPage()
    {
        InitializeComponent();
    }
}

If anyone know how to make works TabbedPage on Android?


Update: I found a solution to my issue. It was a file that won't load when booting on Android. After a few investigations I found out how to load custom files with .NET Maui on this Thread which led me to this page of the Docs.

Thank You!

  • 2
    "an exception" is not a helpful description of the problem. What specific exception are you getting? Have you tried the suggestions in the post you linked to? – Jason Apr 22 '23 at 19:54
  • Yes, I did. My application run well on my Windows PC but not on Android. My frustration is that even for me the exception message is not clear. Visual Studio just prompt me that there is an exception that broke the app and exit. The message point towards this class I pasted. Thank you @Jason for reaching out. – christian80gabi Apr 23 '23 at 20:56
  • Currently Shell can't render `TabbedPage`, `FlyoutPage`, or `NavigationPage`. With Xamarin.Forms the Android shell was too incompatible to make this ever work. For more details, you can refer to [Make Shell compatible with the other page types in .NET MAUI](https://github.com/dotnet/maui/issues/6389). – Alexandar May - MSFT Apr 26 '23 at 04:26
  • Sadly, that does not sound great. Why did they write in the docs about [.NET MAUI Shell tabs](https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/shell/tabs?view=net-maui-7.0) without highlighting that it is not supported on Android? I also switched from `Shell` to `TabbedPage` as it is explained [here](https://learn.microsoft.com/en-us/dotnet/maui/user-interface/pages/tabbedpage?view=net-maui-7.0). However, none of them seem to work on Android only on Windows. I hope they make that cleared soon. Thank you @AlexandarMay-MSFT and @Jason, both for reaching out. – christian80gabi Apr 27 '23 at 11:43
  • 1
    I found a solution to my issue. It was triggered by a file I was trying to load. On Windows It was reading the full path fine but on Android it couldn't access it. I found out how to make that works with Maui and it did. Thank U. – christian80gabi May 08 '23 at 01:43
  • @christian80gabi Good job! If possible, you can post your solution as it's helpful to others facing the same problem. Thanks in advance! – Alexandar May - MSFT May 08 '23 at 07:30

1 Answers1

0

I found a solution. It was a file that won't load when booting on Android. After a few investigations I found out how to load custom files with .NET Maui on this Thread which led me to this page of the Docs.


To summarize, I found that it is not advised to load custom files to a .NET Maui app using:

  • var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Folder", fileName);
  • Or using const string filePath = "FullPath\\to\\File".

Instead, there's a method inside Resources\Raw\AboutAssets.txt directing on how to use assets such as files. Which I did and it works. However, I didn't use the returning async Task method way I just ReadToEnd() the StreamReader as soon as it gets the file path.

For those who are interested can look at my project on GitHub.

Thank You for your HELP!