RadSegmentedConrol handler not found error when running on android

0 Answers 250 Views
SegmentedControl
Jon
Top achievements
Rank 1
Jon asked on 21 Mar 2023, 01:11 AM
Getting handler not found error when xaml has a RadSegmentedControl in it on Android.  It is working in iOS and other Telerik controls are working in Android but not RadSegmentedControl.  Is RadSegmentedConrol supported on Android? 
Didi
Telerik team
commented on 21 Mar 2023, 07:36 AM

Hi Jon, 
You can use the RadSegmentedControl on all platforms - Android, iOS, WinUI and MacCatalyst. I have checked all examples we have and there isn't an exception. https://docs.telerik.com/devtools/maui/demos-and-sample-apps/overview Controls Samples and SDK Browser applications. 

Check whether you have registered the needed handlers by calling the UseTelerik() method inside the MauiProgram.cs file. https://docs.telerik.com/devtools/maui/controls/segmentedcontrol/getting-started#define-the-control 

If you have registered this and still have error, send me a sample project where the behavior occurs. In this was I can research the case further. 

Jon
Top achievements
Rank 1
commented on 21 Mar 2023, 02:08 PM

I added UseTelerik, before it had UseTelerikControls.  Now it has both of them but I still get the same error.  This is a Maui Embedding app (https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/native-embedding?view=net-maui-7.0#android-1)  Not sure if that makes a difference or not. 
Didi
Telerik team
commented on 21 Mar 2023, 02:27 PM

Hi Jon,
The method you have to call in MauiProgram.cs file is UseTelerik(), not UseTelerikConrolsAlso what is the Telerik .NET MAUI version you are using?

Next Steps:

Send me a project where I can research the case further. Also the stack-trace of the exception. 

 


Jon
Top achievements
Rank 1
commented on 21 Mar 2023, 02:41 PM

I can't send the project since it is proprietary code.  Will try to create a sample project later.  Here's the stack trace:

   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 92
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 127
   at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\Layout\LayoutHandler.Android.cs:line 43
   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) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\HandlerImpl\Element\Element.Impl.cs:line 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:line 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:line 303
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 127
   at Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent(IContentViewHandler handler) in D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 44
   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
   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) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 172
   at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 47
   at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 82
   at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 79
   at Microsoft.Maui.Handlers.ViewHandler.SetVirtualView(IElement element) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandler.cs:line 129
   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) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 53
   at Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 27
   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
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\HandlerImpl\Element\Element.Impl.cs:line 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:line 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:line 303
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 127
   at TransportACE.Droid.PageExtensions.ScopedFragment.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) in C:\apacheta_git\TransportACE_HME\TransportACE_Maui\Platforms\Android\Source\Util\PageExtensions.cs:line 33
   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:line 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:line 352
Didi
Telerik team
commented on 21 Mar 2023, 02:49 PM

Hi Jon, 

If you can isolate the issue in a sample, that could be of great help for further researching the case. 

Regarding to the stack-trace, I do not see Telerik mentioned in it. It seems an error related to .NET MAUI framework. I do not see SegmentedControl, Telerik.Maui.Controls, in the stack-trace. 

Jon
Top achievements
Rank 1
commented on 21 Mar 2023, 02:57 PM

I just sent the StackTrace of the exception.  This is the message of the exception: Handler not found for view Telerik.Maui.Controls.RadSegmentedControl.
Jon
Top achievements
Rank 1
commented on 21 Mar 2023, 03:06 PM

I found a workaround for the issue.  I added the following code after .UseTelerik() of builder:

 .ConfigureMauiHandlers((handlers) =>
                    {
#if __ANDROID__
                        handlers.AddHandler(typeof(RadSegmentedControl), typeof(Telerik.Maui.RadSegmentedControlHandler));
#endif
                    })

Not sure if it is related or not, but I noticed the other Telerik Handlers seem to be in Telerik.Maui.Handlers namespace but the RadSegmentedControlHandler is in Telerik.Maui namespace.

 

Didi
Telerik team
commented on 21 Mar 2023, 04:11 PM

Hi Jon, 
For further researching the case on my side I will need a repro project. To check what is the exact setup in what cases the behavior happens.  

What I can suggest for now is adding the -> 

[XamlCompilation(XamlCompilationOptions.Compile)]

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class NestedProperty : RadContentView
{
    public NestedProperty ()
    {
        InitializeComponent ();
        
        this.BindingContext = new ViewModel();
    }
}

in the xaml.cs file where the SegmentedControl is used. 

No answers yet. Maybe you can help?

Tags
SegmentedControl
Asked by
Jon
Top achievements
Rank 1
Share this question
or