Closed nmdaraniya closed 1 year ago
I suspect you need to add a call to UseMauiMaps()
in your app's MauiProgram.cs file, like this:
Hi @nmdaraniya. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
Hi @nmdaraniya. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
I have tried your steps by calling to UseMauiMaps() in your app's MauiProgram.cs file, but still issue is not resolved, i have attached my demo project git repository link , from this demo project you can regenerate the issue. https://github.com/nmdaraniya/Map_Demo_MAUI.git
I have tried your steps by calling to UseMauiMaps() in your app's MauiProgram.cs file, but still issue is not resolved, i have attached my demo project git repository link , from this demo project you can regenerate the issue. https://github.com/nmdaraniya/Map_Demo_MAUI.git
Observed the same behavior in iOS
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
I've been facing the same issue when debugging in andriod as well. I just followed the same set of instructions given in the map documentation [https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/map?view=net-maui-7.0](Maps Documentation)
Here is the debug logs for your information
[eword.phonewor] Explicit concurrent copying GC freed 13956(811KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 3546KB/7092KB, paused 393us total 7.696ms
[OpenGLRenderer] endAllActiveAnimators on 0x7d1e51ec3720 (RippleDrawable) with handle 0x7d1d72ab7f10
Resolved pending breakpoint at 'HomeViewModel.cs:47,1' to void Phoneword.ViewModels.HomeViewModel.
Microsoft.Maui.Platform.HandlerNotFoundException: 'Handler not found for view Microsoft.Maui.Controls.Maps.Map.'
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: Microsoft.Maui.Platform.HandlerNotFoundException: Handler not found for view Microsoft.Maui.Controls.Maps.Map.
[mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 92
[mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 127
[mono-rt] at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view) in D:\a_work\1\s\src\Core\src\Handlers\Layout\LayoutHandler.Android.cs:line 43
[mono-rt] at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56 [mono-rt] at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\HandlerImpl\Element\Element.Impl.cs:line 63 [mono-rt] at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\HandlerImpl\Element\Element.Impl.cs:line 19 [mono-rt] at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\HandlerImpl\VisualElement\VisualElement.Impl.cs:line 294 [mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96 [mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 127 [mono-rt] at Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent(IContentViewHandler handler) in D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 44 [mono-rt] at Microsoft.Maui.Handlers.ContentViewHandler.MapContent(IContentViewHandler handler, IContentView page) in D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 49 [mono-rt] at Microsoft.Maui.PropertyMapper
2.<>cDisplayClass5_0[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IContentViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 53 [mono-rt] at Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 27 [mono-rt] at Microsoft.Maui.Handlers.ViewHandler
2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in D:\a_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56
[mono-rt] at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a_work\1\s\src\Controls\src\Core\HandlerImpl\Element\Element.Impl.cs:line 63
[mono-rt] at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a_work\1\s\src\Controls\src\Core\HandlerImpl\Element\Element.Impl.cs:line 19
[mono-rt] at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in D:\a_work\1\s\src\Controls\src\Core\HandlerImpl\VisualElement\VisualElement.Impl.cs:line 294
[mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96
[mono-rt] at Microsoft.Maui.Platform.ViewExtensions.ToHandler(IView view, IMauiContext context) in D:\a_work\1\s\src\Core\src\Platform\ViewExtensions.cs:line 43
[mono-rt] at Microsoft.Maui.Controls.Platform.Compatibility.ShellContentFragment.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) in D:\a_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellContentFragment.cs:line 145
[mono-rt] at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_osBundle(IntPtr jnienv, IntPtr native
Any news of fixing this bug, I'm seeing the same error in my project, this is the log in case you need it:
Microsoft.Maui.Platform.HandlerNotFoundException: Handler not found for view Microsoft.Maui.Controls.Maps.Map.
at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
at Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent(IContentViewHandler handler)
at Microsoft.Maui.Handlers.ContentViewHandler.MapContent(IContentViewHandler handler, IContentView page)
at Microsoft.Maui.PropertyMapper2.<>c__DisplayClass5_0[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IContentViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v) at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) at Microsoft.Maui.Handlers.ViewHandler
2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view)
at Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView(IView view)
at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) at Microsoft.Maui.Platform.ViewExtensions.ToHandler(IView view, IMauiContext context) at Microsoft.Maui.Controls.Handlers.Items.TemplateHelpers.GetHandler(View view, IMauiContext context) at Microsoft.Maui.Controls.Handlers.Items.TemplatedCell.Bind(DataTemplate template, Object bindingContext, ItemsView itemsView) at Microsoft.Maui.Controls.Handlers.Items.ItemsViewController
1[[Microsoft.Maui.Controls.ReorderableItemsView, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].UpdateTemplatedCell(TemplatedCell cell, NSIndexPath indexPath)
at Microsoft.Maui.Controls.Handlers.Items.ItemsViewController1[[Microsoft.Maui.Controls.ReorderableItemsView, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].CreateMeasurementCell(NSIndexPath indexPath) at Microsoft.Maui.Controls.Handlers.Items.ItemsViewController
1[[Microsoft.Maui.Controls.ReorderableItemsView, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].GetPrototype()
at Microsoft.Maui.Controls.Handlers.Items.ItemsViewLayout.DetermineCellSize()
at Microsoft.Maui.Controls.Handlers.Items.ListViewLayout.ConstrainTo(CGSize size)
at Microsoft.Maui.Controls.Handlers.Items.ItemsViewController1[[Microsoft.Maui.Controls.ReorderableItemsView, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].CheckForEmptySource() at Microsoft.Maui.Controls.Handlers.Items.ItemsViewController
1[[Microsoft.Maui.Controls.ReorderableItemsView, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].NumberOfSections(UICollectionView collectionView)
at UIKit.UICollectionViewLayout.PrepareLayout()
at Microsoft.Maui.Controls.Handlers.Items.ItemsViewLayout.PrepareLayout()
at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
Just a guess, but one of the repro apps seems to be mixing .NET 6 and .NET 7 in the same app.
For example, in https://github.com/nmdaraniya/Map_Demo_MAUI it's using .NET 6 as the target framework: https://github.com/nmdaraniya/Map_Demo_MAUI/blob/master/Map_Demo_MAUI/Map_Demo_MAUI.csproj#L4
But it's using the .NET 7 version of the Maps control: https://github.com/nmdaraniya/Map_Demo_MAUI/blob/master/Map_Demo_MAUI/Map_Demo_MAUI.csproj#L52
Mixing versions like that is not recommended. There was no .NET 6 version of the Maps control, so I suggest trying to update the whole app to .NET 7 and then trying again.
In my case the issue was because i was using a prerelease version (8.0.0-preview.1.7762) when I replaced it for the Microsoft.Maui.Controls.Maps.7.0.59 everything start working as expected.
In my case the issue was because i was using a prerelease version (8.0.0-preview.1.7762) when I replaced it for the Microsoft.Maui.Controls.Maps.7.0.59 everything start working as expected.
Great, I'm glad you got it working! We call this situation "crossing the streams" (mixing major versions of things), and it's never a good idea, but it's easy to do by accident!
I had the same preview version - it doesn't help that that's the default option when installing the nuget package.
I had the same preview version - it doesn't help that that's the default option when installing the nuget package.
Understood and agreed. Unfortunately there's no way in NuGet packages to specify the precise rules governing how each package can be used. This is a case where theoretically it could work, but in practice it doesn't (apparently).
In my case the issue was because i was using a prerelease version (8.0.0-preview.1.7762) when I replaced it for the Microsoft.Maui.Controls.Maps.7.0.59 everything start working as expected.
I have the same version (7.0.59) and still have this problem :(
Still a Problem on version 7.0.8.1
I have tried 7.0.59 and its still giving the same error
This was my problem and also my solution!
The android target runtime was set to .net 6. Changed it to .net 7 and it works just in time for my school assesment :)
For anyone running into issues like this, please read my comment here: https://github.com/dotnet/maui/issues/12320#issuecomment-1466450487
If you are still experiencing this problem, please post the contents of your CSPROJ file (so we can check the versions of everything), and your MauiProgram.cs
file (so we can check the relevant startup code). You can omit any private or sensitive data.
Don´t know why but bumping up the min supported ios version to 14.2 in the csproj file "fixed" the issue for me.
Hi @nmdaraniya. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.
You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
Verified this issue with Visual Studio Enterprise 17.7.0 Preview 3.0(net8). Not repro on Android platform with sample project. https://github.com/nmdaraniya/Map_Demo_MAUI
Still have this problem with the latest version and other versions mentioned here (i.e., 7.0.49, 7.0.59) - is there still no fix?
.csproj file
@K-Ketchup in your CSPROJ file it looks like there's a mix of .NET 8 and .NET 7 versions.
This is using .NET 7 (net7
-XYZ):
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
And this is using a mix of 7.0-XYZ and 8.0-XYZ:
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0-preview.7.23375.6" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0-preview.7.23375.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0-preview.7.23375.6" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0-preview.7.23375.6" />
<PackageReference Include="Microsoft.Maui.Controls.Maps" Version="7.0.49" />
I'm not sure if it's the cause of the problem you're seeing, but I wouldn't expect it to work.
Also, can you confirm you're seeing the exact same error?
Sorry about that, it seems like my error itself is different from the one mentioned here. I did try fixing the package versions but that didn't seem to work. I presume this is an issue with the Microsoft.Maui.Controls.Maps nuget package since I had trouble declaring it as a namespace at the top of my main view.
[0:] An error occurred: 'Handler not found for view Microsoft.Maui.Controls.Maps.Map.'. Callstack: ' at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view)
at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
at Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent(IContentViewHandler handler)
at Microsoft.Maui.Handlers.ContentViewHandler.MapContent(IContentViewHandler handler, IContentView page)
at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IContentViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v)
at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView)
at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView)
at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view)
at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view)
at Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView(IView view)
at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
at Microsoft.Maui.Platform.ViewExtensions.ToHandler(IView view, IMauiContext context)
at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.SetPageRenderer(Page page, ShellContent shellContent)
at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.LoadRenderers()
at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.ViewDidLoad()
at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
at Dook.Program.Main(String[] args) in C:\Users\yoboi\source\repos\Dook\Platforms\iOS\Program.cs:line 13
at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)'
The app has been terminated.
@K-Ketchup does it work in a brand new MAUI app that you create from scratch? If nothing works, please upload a simple repro app to a public GitHub repo and we can take a look. I'm pretty sure the Maps package is working for most people so we'll have to see what's different in your project. Thanks!
I've found a fix. The MauiProgram.cs file seemed to be the issue.
Changed the file from
using Microsoft.Extensions.Logging;
namespace Dook;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiMaps()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}
To
using Microsoft.Extensions.Logging;
namespace Dook
{
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
})
.UseMauiMaps();
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}
}
@K-Ketchup : Interesting - so calling UseMauiMaps()
after ConfigureFonts()
is what fixed it? That sounds like it could be a bug.
I filed https://github.com/dotnet/maui/issues/16736 to track that.
I have below code in my NewPage1.xaml
When I am trying to run my application its throwing below error,