{"record":{"id":"7e3520dd92c98131","repo":"dotnet/maui","slug":"element-gettype-fullname-is-not-compatible-e","errorCode":null,"errorMessage":"{element?.GetType().FullName} is not compatible. element must be of type ActivityIndicator.","messagePattern":"(.+?) is not compatible\\. element must be of type ActivityIndicator\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Material/src/Android/MaterialActivityIndicatorRenderer.cs","lineNumber":170,"sourceCode":"\t\t{\n\t\t\tif (Element != null && _control != null)\n\t\t\t\t_control.SetBackground(Element.BackgroundColor, Element.Background);\n\t\t}\n\n\t\t// IVisualElementRenderer\n\t\tVisualElement IVisualElementRenderer.Element => Element;\n\t\tVisualElementTracker IVisualElementRenderer.Tracker => _visualElementTracker;\n\t\tAView IVisualElementRenderer.View => this;\n\n\t\tSizeRequest IVisualElementRenderer.GetDesiredSize(int widthConstraint, int heightConstraint)\n\t\t{\n\t\t\t_control.Measure(widthConstraint, heightConstraint);\n\t\t\treturn new SizeRequest(new Size(Control.MeasuredWidth, Control.MeasuredHeight), new Size());\n\t\t}\n\n\t\tvoid IVisualElementRenderer.SetElement(VisualElement element) =>\n\t\t\tElement = (element as ActivityIndicator) ??\n\t\t\t\tthrow new ArgumentException($\"{element?.GetType().FullName} is not compatible. {nameof(element)} must be of type {nameof(ActivityIndicator)}.\");\n\n\t\tvoid IVisualElementRenderer.SetLabelFor(int? id)\n\t\t{\n\t\t\tif (_defaultLabelFor == null)\n\t\t\t\t_defaultLabelFor = ViewCompat.GetLabelFor(this);\n\n\t\t\tViewCompat.SetLabelFor(this, (int)(id ?? _defaultLabelFor));\n\t\t}\n\n\t\tvoid IVisualElementRenderer.UpdateLayout() =>\n\t\t\t_visualElementTracker?.UpdateLayout();\n\n\t\t// IViewRenderer\n\t\tvoid IViewRenderer.MeasureExactly() =>\n\t\t\tViewRenderer.MeasureExactly(_control, Element, Context);\n\n\t\t// ITabStop\n\t\tAView ITabStop.TabStop => _control;","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Material/src/Android/MaterialActivityIndicatorRenderer.cs#L152-L188","documentation":"MaterialActivityIndicatorRenderer is the Material Design renderer for ActivityIndicator on Android. Its SetElement implementation casts the incoming VisualElement to ActivityIndicator and throws ArgumentException if the cast fails. This enforces the one-to-one mapping between renderer and element type — the renderer cannot track or render an incompatible element.","triggerScenarios":"The MAUI handler/renderer registry dispatches a non-ActivityIndicator element to MaterialActivityIndicatorRenderer. This happens when ExportRenderer or RegisterHandler registrations are misconfigured, or when a custom registrar maps the wrong element type to this renderer.","commonSituations":"Custom ExportRenderer attributes that incorrectly pair an element type with the wrong renderer. Migrating from Xamarin.Forms to MAUI and leaving stale renderer registrations. Using a Material visual with a custom control that does not derive from ActivityIndicator.","solutions":["Verify the ExportRenderer/HandlerRegistration attribute pairs ActivityIndicator with MaterialActivityIndicatorRenderer.","Ensure any custom control you want rendered by this renderer derives from ActivityIndicator.","Check for duplicate or conflicting renderer registrations across assemblies.","If using the Material visual (`VisualMarker.Material`), confirm the element type is one Material supports."],"exampleFix":"// before (wrong mapping)\n[assembly: ExportRenderer(typeof(ProgressBar), typeof(MaterialActivityIndicatorRenderer))]\n\n// after (correct mapping)\n[assembly: ExportRenderer(typeof(ActivityIndicator), typeof(MaterialActivityIndicatorRenderer))]","handlingStrategy":"type-guard","validationCode":"if (element is not ActivityIndicator)\n    throw new InvalidOperationException($\"Expected ActivityIndicator, got {element?.GetType().Name}\");\nrenderer.SetElement(element);","typeGuard":"static bool IsActivityIndicator(VisualElement? element) => element is ActivityIndicator;","tryCatchPattern":null,"preventionTips":["Double-check ExportRenderer/HandlerRegistration pairs element type to renderer type.","Ensure custom controls derive from the correct base element (ActivityIndicator).","Audit renderer registrations across all assemblies during build."],"tags":["maui","android","material","renderer","type-mismatch","activity-indicator"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}