{"record":{"id":"7c9a62f1b6723c2b","repo":"AvaloniaUI/Avalonia","slug":"androidplatformoptions-renderingmode-must-not-be-e","errorCode":null,"errorMessage":"AndroidPlatformOptions.RenderingMode must not be empty or null","messagePattern":"AndroidPlatformOptions\\.RenderingMode must not be empty or null","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Android/Avalonia.Android/AndroidPlatform.cs","lineNumber":112,"sourceCode":"                .Bind<PlatformHotkeyConfiguration>().ToSingleton<PlatformHotkeyConfiguration>()\n                .Bind<KeyGestureFormatInfo>().ToConstant(new KeyGestureFormatInfo(new Dictionary<Key, string>() { }))\n                .Bind<IActivatableLifetime>().ToConstant(new AndroidActivatableLifetime());\n\n            var graphics = InitializeGraphics(Options);\n            if (graphics is not null)\n            {\n                AvaloniaLocator.CurrentMutable.Bind<IPlatformGraphics>().ToConstant(graphics);\n            }\n\n            Compositor = new Compositor(graphics);\n            AvaloniaLocator.CurrentMutable.Bind<Compositor>().ToConstant(Compositor);\n        }\n        \n        private static IPlatformGraphics? InitializeGraphics(AndroidPlatformOptions opts)\n        {\n            if (opts.RenderingMode is null || !opts.RenderingMode.Any())\n            {\n                throw new InvalidOperationException($\"{nameof(AndroidPlatformOptions)}.{nameof(AndroidPlatformOptions.RenderingMode)} must not be empty or null\");\n            }\n\n            foreach (var renderingMode in opts.RenderingMode)\n            {\n                if (renderingMode == AndroidRenderingMode.Software)\n                {\n                    return null;\n                }\n\n                if (renderingMode == AndroidRenderingMode.Egl)\n                {\n                    if (EglPlatformGraphics.TryCreate() is { } egl)\n                    {\n                        return egl;\n                    }\n                }\n\n                if (renderingMode == AndroidRenderingMode.Vulkan)","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Android/Avalonia.Android/AndroidPlatform.cs#L94-L130","documentation":"InitializeGraphics requires the user-supplied AndroidPlatformOptions.RenderingMode collection to be non-null and non-empty; it iterates the list to pick Software/EGL/Vulkan. An empty or null list gives the framework nothing to try, so it throws at the top of InitializeGraphics.","triggerScenarios":"Constructing AvaloniaAndroid with AndroidPlatformOptions.RenderingMode == null or an empty IEnumerable (e.g. new() or []). The platform cannot pick a renderer.","commonSituations":"Overriding default options and forgetting RenderingMode; clearing the list; deserializing options from config that omitted the field; passing new AndroidPlatformOptions() after the default was removed.","solutions":["Set AndroidPlatformOptions.RenderingMode to at least one valid mode, e.g. new() { AndroidRenderingMode.Egl }.","Use the default AndroidPlatformOptions (which already lists Software + Egl + Vulkan).","Always include AndroidRenderingMode.Software as a guaranteed fallback.","Validate options before handing them to With(new AndroidPlatformOptions { ... })."],"exampleFix":"// before\nAppBuilder.Configure<AvaloniaAndroid>()\n    .With(new AndroidPlatformOptions { RenderingMode = new List<AndroidRenderingMode>() });\n\n// after (always provide a non-empty list with a software fallback)\nAppBuilder.Configure<AvaloniaAndroid>()\n    .With(new AndroidPlatformOptions\n    {\n        RenderingMode = new List<AndroidRenderingMode> { AndroidRenderingMode.Egl, AndroidRenderingMode.Software }\n    });","handlingStrategy":"validation","validationCode":"// ensure a non-empty rendering-mode list with a software fallback\nopts.RenderingMode ??= new List<AndroidRenderingMode>();\nif (opts.RenderingMode.Count == 0)\n    opts.RenderingMode.Add(AndroidRenderingMode.Software);","typeGuard":"static bool IsValid(AndroidPlatformOptions o) => o.RenderingMode is not null && o.RenderingMode.Any();","tryCatchPattern":"// pure validation — no recoverable catch; fix the options before passing them.","preventionTips":["Always include AndroidRenderingMode.Software as the last fallback.","Use the default AndroidPlatformOptions.","Validate options in a test."],"tags":["android","platform-options","rendering","config","egl","vulkan","software"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}