Maui Android Crash CarouselView IndicatorView on navigating second time
See original GitHub issueDescription
Maui Android Crash when there is CarouselView with IndicatorView and navigating second time to the page .
`
<CarouselView ItemsSource="{Binding Item.ProductFiles}" IndicatorView="myIndicator">
<CarouselView.ItemTemplate>
<DataTemplate x:DataType="model:ProductFileV2">
<StackLayout>
<Frame HasShadow="True"
BorderColor="DarkGray"
CornerRadius="5"
Margin="20"
HeightRequest="300"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand">
<StackLayout>
<local:PinchToZoomContainer>
<Image Source="{Binding ThumbnailHostPathPublic}"
Aspect="AspectFill"
HeightRequest="150"
WidthRequest="150"
HorizontalOptions="Center" />
</local:PinchToZoomContainer>
</StackLayout>
</Frame>
</StackLayout>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
<IndicatorView x:Name="myIndicator"
IndicatorColor="LightGray"
SelectedIndicatorColor="DarkGray"
HorizontalOptions="Center" />
public ObservableCollection<ProductFile> ProductFileList { get; set; } = new ObservableCollection<ProductFile>(); void LoadProductFiles() { if (IsBusyProductFiles) { return; } IsBusyProductFiles = true;
Task.Run(async () =>
{
var items = await _ProductService.GetProductFiles(SearchModel);
Application.Current.Dispatcher.Dispatch(() =>
{
ProductFileList.Clear();
items?.Where(p => p.ProductFileType?.ProductFileTypeAction == ProductFileTypeAction.IsGallery)?
.OrderBy(p => p.Importance)?
.ToList()?.ForEach(p => ProductFileList.Add(p));
IsBusyProductFiles = false;
});
});
}
Steps to Reproduce
Link to public reproduction project repository
dont have
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android
Did you find any workaround?
No
Relevant log output
Time Device Name Type PID Tag Message
11-12 16:40:11.425 pixel_5_-_api_33 Error 1788 AndroidRuntime android.runtime.JavaProxyThrowable: System.InvalidOperationException: PlatformView cannot be null here
at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IIndicatorView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.MauiPageControl, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].get_PlatformView()
at Microsoft.Maui.Handlers.IndicatorViewHandler.OnDisconnectHandler(View platformView)
at Microsoft.Maui.Handlers.ViewHandler.OnDisconnectHandler(Object platformView)
at Microsoft.Maui.Handlers.ElementHandler.DisconnectHandler(Object platformView)
at Microsoft.Maui.Handlers.ElementHandler.Microsoft.Maui.IElementHandler.DisconnectHandler()
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.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.LayoutViewGroup, 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.SetVirtualView(IElement element)
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(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.ContentViewGroup, 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.ShellContentFragment.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_inflater, IntPtr native_container, IntPtr native_savedInstanceState)
at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(_JniMarshal_PPLLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1, IntPtr p2)
at crc640ec207abc449b2ca.ShellContentFragment.n_onCreateView(Native Method)
at crc640ec207abc449b2ca.ShellContentFragment.onCreateView(ShellContentFragment.java:62)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3104)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:524)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1890)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1808)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1751)
at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:538)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7892)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Issue Analytics
- State:
- Created 10 months ago
- Reactions:2
- Comments:7 (1 by maintainers)
Top Results From Across the Web
CarouselView crashes Android app when using ...
CarouselView always worked since I started learning .NET MAUI but for some reason now it doesn't work anymore. I haven't done anything strange ......
Read more >Xamarin.Forms 5.0.0.2612 (5.0.0 Service Release 15) ...
Forms 5 brings to stable release several new controls and features including App Themes (Dark Mode), Brushes, CarouselView, RadioButton, ...
Read more >Display Rich Data with CollectionView - .NET MAUI Tutorial ...
This video is part of a crash course to build your first .NET MAUI app. The next part in this tutorial is ready...
Read more >net maui Archives
ItemsSource> </CarouselView> <IndicatorView x:Name="indicatorView" Grid. ... After having put down the migration for a second time, I picked it up again ...
Read more >.NET MAUI android application crashes immediately after ...
I've run into this problem several times and it was always fixable by looking at the logs. Upvote 1
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This fixes it for me until it is patched. Based on #12141
Works Great For Me