I'm getting this exception after updating Xamarin.Forms to version 4.7.0.968
Stack trace:
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.ArgumentException: element must be of type Button
[MonoDroid] at Xamarin.Forms.Platform.Android.RadioButtonRenderer.Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00016] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\RadioButtonRenderer.cs:102
[MonoDroid] at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:350
[MonoDroid] at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000b3] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:140
[MonoDroid] at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00163] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:351
[MonoDroid] at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:112
[MonoDroid] at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:465
[MonoDroid] at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000d5] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:245
[MonoDroid] at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00033] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:135
[MonoDroid] at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:350
[MonoDroid] at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000b3] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:140
[MonoDroid] at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:112
[MonoDroi10-16 12:32:01.021 I] at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:465
[MonoDroid] at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000d5] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:245
[MonoDroid] at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00033] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:135
[MonoDroid] at Xamarin.Forms.Platform.Android.ViewCellRenderer.GetCellCore (Xamarin.Forms.Cell item, Android.Views.View convertView, Android.Views.ViewGroup parent, Android.Content.Context context) [0x000a4] in D:\a\1\s\Xamarin.Forms.Platform.Android\Cells\ViewCellRenderer.cs:44
[MonoDroid] at Xamarin.Forms.Platform.Android.CellRenderer.GetCell (Xamarin.Forms.Cell item, Android.Views.View convertView, Android.Views.ViewGroup parent, Android.Content.Context context) [0x00075] in D:\a\1\s\Xamarin.Forms.Platform.Android\Cells\CellRenderer.cs:51
[MonoDroid] at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00163] in D:\a\1\s\Xamarin.Forparent, Android.Content.Context context, Xamarin.Forms.View view) [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.Android\Cells\CellFactory.cs:20
[MonoDroid] at Xamarin.Forms.Platform.Android.ListViewAdapter.GetView (System.Int32 position, Android.Views.View convertView, Android.Views.ViewGroup parent) [0x00211] in D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:304
[MonoDroid] at Android.Widget.BaseAdapter.n_GetView_ILandroid_view_View_Landroid_view_ViewGroup_ (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 position, System.IntPtr native_convertView, System.IntPtr native_parent) [0x00019] in /Users/builder/azdo/_work/287/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-29/mcw/Android.Widget.BaseAdapter.cs:521
[MonoDroid] at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.124(intptr,intptr,int,intptr,intptr)
[Mono] Probing 'java_interop_jnienv_throw'.
[Mono] Found as 'java_interop_jnienv_throw'.
I have reported bug on GitHub: Check Bug
Anyone know how to handle this exception or fix this issue?
Thanks to @GeraldVersluis for the answer to the bug I have reported on GitHub I have got the solution. Here is the solution:
Ah, you are not using the built-in RadioButton at all? You have created your own? It might be some naming conflict. I would rename the RadioButtonRenderer to CustomRadioButtonRenderer and see if that works better. This is because of Xamarin.Forms have a RadioButton now too.
Then I have just changed my Renderer name as he suggested to CustomRadioButtonRenderer and it's started working fine after that.