Skip to content

Android - Setting TabPage Tab color causes System.NullRefException  #12904

@sstahurski

Description

@sstahurski

Description

Android - Setting TabPage Tab color causes System.NullRefException
Works in IOS, other platforms not tested.

Steps to Reproduce

Create a tabpage.
Set the SelectedTabColor in either the Xaml or in code for the TabbedPage

Link to public reproduction project repository

https://github.com/sstahurski/testTab

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android API 31

Did you find any workaround?

No

Relevant log output

System.NullReferenceException: Object reference not set to an instance of an object.
  at Microsoft.Maui.Graphics.Platform.GraphicsExtensions.AsColor(Color target) in D:\a\_work\1\s\src\Graphics\src\Graphics\Platforms\Android\GraphicsExtensions.cs:28
  at Microsoft.Maui.Platform.ColorExtensions.ToPlatform(Color self) in D:\a\_work\1\s\src\Core\src\Platform\Android\ColorExtensions.cs:14
  at Microsoft.Maui.Controls.Handlers.TabbedPageManager.GetItemTextColorStates() in D:\a\_work\1\s\src\Controls\src\Core\Platform\Android\TabbedPageManager.cs:533
  at Microsoft.Maui.Controls.Handlers.TabbedPageManager.UpdateBarTextColor() in D:\a\_work\1\s\src\Controls\src\Core\Platform\Android\TabbedPageManager.cs:653
  at Microsoft.Maui.Controls.Handlers.TabbedPageManager.UpdateTabItemStyle() in D:\a\_work\1\s\src\Controls\src\Core\Platform\Android\TabbedPageManager.cs:645
  at Microsoft.Maui.Controls.TabbedPage.MapBarTextColor(ITabbedViewHandler handler, TabbedPage view) in D:\a\_work\1\s\src\Controls\src\Core\HandlerImpl\TabbedPage\TabbedPage.Android.cs:65
  at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.Controls.TabbedPage, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.ITabbedViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:172
  at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:47
  at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:82
  at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:79
  at Microsoft.Maui.Handlers.ViewHandler.SetVirtualView(IElement element) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandler.cs:129
  at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ITabbedView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Android.Views.View, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:53
  at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ITabbedView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Android.Views.View, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:56
  at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\HandlerImpl\Element\Element.Impl.cs:69
  at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\HandlerImpl\Element\Element.Impl.cs:19
  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:303
  at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:96
  at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:127
  at Microsoft.Maui.Platform.ScopedFragment.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) in D:\a\_work\1\s\src\Core\src\Platform\Android\Navigation\ScopedFragment.cs:22
  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) in /Users/runner/work/1/s/generated/androidx.fragment.fragment/obj/Release/net6.0-android/generated/src/AndroidX.Fragment.App.Fragment.cs:2031
  at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(_JniMarshal_PPLLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1, IntPtr p2) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:352

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions