C# 未处理的异常:System.ArgumentException:元素的类型必须为Button(Xamarin.Forms-Android)
我在将Xamarin.Forms更新到4.7.0.968版后遇到此异常 堆栈跟踪:C# 未处理的异常:System.ArgumentException:元素的类型必须为Button(Xamarin.Forms-Android),c#,android,xamarin,xamarin.forms,xamarin.android,C#,Android,Xamarin,Xamarin.forms,Xamarin.android,我在将Xamarin.Forms更新到4.7.0.968版后遇到此异常 堆栈跟踪: [MonoDroid] UNHANDLED EXCEPTION: [MonoDroid] System.ArgumentException: element must be of type Button [MonoDroid] at Xamarin.Forms.Platform.Android.RadioButtonRenderer.Xamarin.Forms.Platform.Android.IVisual
[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'.
我报告了GitHub上的错误:
有人知道如何处理此异常或修复此问题吗?是否对单选按钮使用自定义渲染器?这可能是一个问题感谢@GeraldVersluis为我在GitHub上报告的bug提供了答案,我得到了解决方案。以下是解决方案: 啊,你根本不用内置的单选按钮?你创造了你自己的?这可能是命名冲突。我会将RadioButtonRenderer重命名为CustomRadioButtonRenderer,看看是否效果更好。这是因为Xamarin。表单现在也有一个单选按钮
然后,我刚刚按照他建议的那样将渲染器名称更改为CustomRadioButtonRenderer,之后它就开始正常工作了。我在GitHub上为您的问题添加了一条评论我已经更新了GitHub ticket@GeraldVersluis