Avalonia Mobile logo

Avalonia Mobile

Community
linuxdevel
avalonia-mobile

Use when building or fixing the Android or iOS (and Mac Catalyst) app side of an Avalonia app — project heads and startup per version (AvaloniaAndroidApplication, AvaloniaMainActivity, AvaloniaAppDelegate, IActivityApplicationLifetime vs ISingleViewApplicationLifetime), safe areas/edge-to-edge (IInsetsManager), soft keyboard (IInputPane), back button, orientation, app activation/background, haptics (PlatformFeedback), touch behavior, and mobile storage/launcher. For packaging/signing see avalonia-deployment.

Overview

Publisherlinuxdevel
RepositoryAvalonia-skills
Skill nameavalonia-mobile
Stars
50
Forks
4
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by linuxdevel on GitHub. Read the source before you install it.

Installation

Install the Avalonia Mobile AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/linuxdevel/Avalonia-skills/tree/main/skills/avalonia/avalonia-mobile
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/linuxdevel/Avalonia-skills.git /tmp/Avalonia-skills
mkdir -p .claude/skills
cp -r /tmp/Avalonia-skills/skills/avalonia/avalonia-mobile .claude/skills/avalonia-mobile
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Avalonia Mobile in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Avalonia Mobile on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Avalonia Mobile is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Avalonia Mobile (Android & iOS)

App-level concerns only. Packaging, signing, APK/IPA publishing: see avalonia-deployment. Version labels: see avalonia-versions.

Requirements

11.x12.0 / 12.1
TFMnet*-android / net*-ios (pre-net10)net10.0-android / net10.0-ios (net10.0 required)
Mac Catalystno(12.0+) net10.0-maccatalyst via Avalonia.iOS package
PackagesAvalonia.Android / Avalonia.iOSsame, version must match core Avalonia

Standard solution layout (from avalonia-dotnet-templates xplat template): shared App project + *.Android head + *.iOS head (+ Desktop/Browser). Template defaults: Android SupportedOSPlatformVersion 23, iOS 13.0, AndroidX SplashScreen package referenced.

Android startup

(12.0+) Application class + activity

csharp
// Application.cs — initialization moved here from the activity
[Application]
public class AndroidApp : AvaloniaAndroidApplication<App>
{
    public AndroidApp(IntPtr javaReference, JniHandleOwnership transfer)
        : base(javaReference, transfer) { }

    protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
        => base.CustomizeAppBuilder(builder).WithInterFont();
}

// MainActivity.cs — non-generic
[Activity(
    Label = "MyApp",
    Theme = "@style/MyTheme.NoActionBar",
    Icon = "@drawable/icon",
    MainLauncher = true,
    ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)]
public class MainActivity : AvaloniaMainActivity { }

CreateAppBuilder() / CustomizeAppBuilder() were removed from AvaloniaMainActivity — put builder customization in the AvaloniaAndroidApplication<TApp> subclass or App. (The IntPtr, JniHandleOwnership constructor is the standard .NET-Android requirement for Application subclasses; the template may omit/inline it — copy from the generated head.)

Type chain: AppCompatActivity -> AvaloniaActivity -> AvaloniaMainActivity.

(12.0+) App.axaml.cs — set the main view

csharp
public override void OnFrameworkInitializationCompleted()
{
    switch (ApplicationLifetime)
    {
        case IClassicDesktopStyleApplicationLifetime desktop:
            desktop.MainWindow = new MainWindow();
            break;
        case IActivityApplicationLifetime activity:        // Android (12.0+)
            activity.MainViewFactory = () => new MainView();  // Func<Control>
            break;
        case ISingleViewApplicationLifetime single:        // iOS, Browser, embedded Linux
            single.MainView = new MainView();
            break;
    }
    base.OnFrameworkInitializationCompleted();
}

Android no longer uses ISingleViewApplicationLifetime; keep that branch for iOS/Browser. Use a factory (a new view per activity instance), not a shared instance.

(11.x) Generic activity + single view

csharp
[Activity(Label = "MyApp", MainLauncher = true, Theme = "@style/MyTheme.NoActionBar",
    ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)]
public class MainActivity : AvaloniaMainActivity<App>
{
    protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
        => base.CustomizeAppBuilder(builder).WithInterFont();
}
// App: case ISingleViewApplicationLifetime single: single.MainView = new MainView();

Multiple activities (12.0+)

Android may create several instances of the main activity in one process (notification tap, return from another app), and 12.0 lets later activities use your project's Application class. IActivityApplicationLifetime.MainViewFactory (Func<Control>) is called once per new activity instance, so each gets a fresh view with its own state. Never set ISingleViewApplicationLifetime.MainView on Android 12 — the Android lifetime implements both interfaces and wraps MainView in a factory returning the same instance, so a second activity shows a blank screen. The lifetime holds only the factory; keep your own reference if you need the current view. Extra (non-main) activities subclass AvaloniaActivity (AppCompatActivity -> AvaloniaActivity) and set its Content property. AvaloniaActivity also has ActivityResult, RequestPermissionsResult (both Action<...>), event BackRequested, and OnBackPressed() / OnBackInvoked().

Rendering mode

csharp
// in AvaloniaAndroidApplication<TApp>.CustomizeAppBuilder
.With(new AndroidPlatformOptions
{
    RenderingMode = new[] { AndroidRenderingMode.Egl, AndroidRenderingMode.Software }
})

AndroidRenderingMode: Egl (default GPU), Vulkan, Software. First mode that initializes wins; empty list or all failing throws InvalidOperationException — keep Software as fallback.

iOS / Mac Catalyst startup

csharp
[Register("AppDelegate")]
public partial class AppDelegate : AvaloniaAppDelegate<App>
{
    protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
        => base.CustomizeAppBuilder(builder)
            .WithInterFont()
            .With(new iOSPlatformOptions
            {
                RenderingMode = new[] { iOSRenderingMode.Metal, iOSRenderingMode.OpenGl },
                EnableHighRefreshRate = false   // opt out of high refresh rate
            });
}
  • iOS uses ISingleViewApplicationLifetime (MainView) in all versions.
  • (12.0+) Scene-based lifecycle: a scene delegate is managed internally; most apps need no changes. AvaloniaAppDelegate.Window stays null after startup — to reach the UIWindow, override AvaloniaView.MovedToWindow.
  • (12.0+) Mac Catalyst: <TargetFrameworks>net10.0-ios;net10.0-maccatalyst</TargetFrameworks>; dotnet workload install maccatalyst, dotnet run -f net10.0-maccatalyst.
  • Embedding: Avalonia.iOS.AvaloniaView (UIKit view hosting Avalonia content), Avalonia.Android.AvaloniaView on Android.

Safe areas & edge-to-edge — IInsetsManager

csharp
var insets = TopLevel.GetTopLevel(this)?.InsetsManager;   // IInsetsManager?
if (insets is not null)
{
    insets.DisplayEdgeToEdgePreference = true;      // draw behind system bars
    insets.IsSystemBarVisible = true;               // bool?
    insets.SystemBarColor = Colors.Black;           // Color?
    Thickness pad = insets.SafeAreaPadding;         // notches, bars, (keyboard excluded)
    insets.SafeAreaChanged += (_, e) => Padding = e.SafeAreaPadding;   // SafeAreaChangedArgs
}
MemberNotes
DisplayEdgeToEdgePreference (bool)Request edge-to-edge. Replaces DisplayEdgeToEdge (removed in 12)
DisplaysEdgeToEdgeActual current state
SafeAreaPadding (Thickness) / SafeAreaChangedCurrent safe-area insets / change event
IsSystemBarVisible (bool?), SystemBarColor (Color?)System bar control

Also on TopLevel: attached SystemBarColor (TopLevel.SetSystemBarColor(control, SolidColorBrush?) / GetSystemBarColor) and TopLevel.GetAutoSafeAreaPadding / SetAutoSafeAreaPadding (whether the TopLevel auto-pads for the safe area). SystemBarTheme enum: Light (light bar background, dark foreground) / Dark.

When drawing edge-to-edge, apply SafeAreaPadding to your root layout (or rely on auto safe-area padding) so content isn't under notches/home indicator.

Soft keyboard — IInputPane

csharp
var pane = TopLevel.GetTopLevel(this)?.InputPane;   // IInputPane?
pane!.StateChanged += (_, e) =>
{
    // e.NewState: InputPaneState.Open / Closed
    // e.EndRect: final keyboard bounds; e.StartRect (Rect?); e.AnimationDuration; e.Easing
    BottomSpacer.Height = e.NewState == InputPaneState.Open ? e.EndRect.Height : 0;
};
var occluded = pane.OccludedRect;   // current keyboard bounds
  • Closed also means "keyboard floating / overlay and not part of insets".
  • To request showing the keyboard: TextInputMethodClient.ShowInputPanel was removed in 12; the client now raises InputPaneActivationRequested (EventHandler) and the platform decides. Don't call a show method yourself — focus a TextBox.

Back button

csharp
var top = TopLevel.GetTopLevel(this)!;
top.BackRequested += (_, e) =>      // EventHandler<RoutedEventArgs>, "physical Back Button pressed or back navigation requested"
{
    if (Nav.CanGoBack) { Nav.GoBack(); e.Handled = true; }
};

Android-specific (12.0+, per AvaloniaActivity): event BackRequested of EventHandler<AndroidBackRequestedEventArgs> (has bool Handled), plus OnBackPressed() / OnBackInvoked(). Set Handled = true to stop the default (finishing the activity); do not leave it unhandled when you consumed the back action.

Orientation

  • Lock in the Android activity: [Activity(..., ScreenOrientation = ScreenOrientation.Portrait)] (Android attribute). Keep ConfigurationChanges = Orientation | ScreenSize | UiMode so rotation doesn't recreate the activity.
  • iOS: set supported orientations in Info.plist (UISupportedInterfaceOrientations).
  • Read at runtime: TopLevel.Screens?.Primary?.CurrentOrientation -> Avalonia.Platform.ScreenOrientation (None, Landscape, LandscapeFlipped, Portrait, PortraitFlipped). React to size changes via layout size changes rather than polling.

App lifecycle — IActivatableLifetime

csharp
if (Application.Current?.TryGetFeature<IActivatableLifetime>() is { } life)
{
    life.Activated   += (_, e) => { /* e.Kind: ActivationKind.Background / File / OpenUri / Reopen */ };
    life.Deactivated += (_, e) => { if (e.Kind == ActivationKind.Background) SaveState(); };
}
  • ActivatedEventArgs.Kind is an ActivationKind: Background (enter/leave background), File (FileActivatedEventArgs.Files), OpenUri (ProtocolActivatedEventArgs.Uri), Reopen (macOS).
  • Replaces IActivatableApplicationLifetime / IApplicationPlatformEvents (removed in 12). In 11.x use (ApplicationLifetime as IActivatableApplicationLifetime).
  • Android: IAvaloniaActivity.Activated/Deactivated per activity; file/URI intents arrive as FileActivatedEventArgs / ProtocolActivatedEventArgs. Register intent filters on the activity ([IntentFilter(...)]) — see Avalonia docs "Register your app to open files".
  • iOS: protocol/universal links are delivered as ProtocolActivatedEventArgs with Kind == ActivationKind.OpenUri.
  • Save state on Deactivated (background) — mobile OSes may kill the process without further notice.

Haptics & sound — PlatformFeedback (12.1+)

csharp
// Opt a control in (default is FeedbackType.None for custom controls)
PlatformFeedback.SetFeedbackType(this, FeedbackType.Auto);   // None, Auto, Sound, Haptic
this.PerformFeedback(FeedbackAction.Click);                  // extension on InputElement; also FeedbackAction.Hold
xml
<Button PlatformFeedback.FeedbackType="Auto" />

Namespace Avalonia.Controls. Implemented on Android and iOS. FeedbackAction cannot be constructed by apps (internal constructor). Not available in 12.0/11.x.

System theme (12.1+ on Android)

12.1 detects Android system theme (dark/light) changes at runtime; earlier versions only read it at startup. Keep RequestedThemeVariant = Default (don't hard-set Light/Dark) to follow the OS, and handle ConfigChanges.UiMode on the activity. Read with TopLevel.PlatformSettings?.GetColorValues().ThemeVariant (11.x) or visual.GetPlatformSettings() (12.x).

Touch input

  • (12.0+) Touch/pen select and focus on pointer release, not press; ListBoxItem/TreeViewItem handle their own selection. 11.x selects on press — don't write 12 code that depends on press-selection from touch.
  • (12.0+) Gesture events (e.g. Pinch) are directly on InputElement, no Gestures. prefix in XAML.
  • Hover (:pointerover) styling is meaningless on touch; use :pressed.
  • Make hit targets at least ~44x44 dp (MinHeight/MinWidth).

Storage, permissions, launcher

csharp
var top = TopLevel.GetTopLevel(this)!;
var files = await top.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions { AllowMultiple = false });
await using var s = await files[0].OpenReadAsync();          // use streams, not paths
await top.Launcher.LaunchUriAsync(new Uri("https://avaloniaui.net"));
  • Android pickers go through the system document picker (content URIs); iOS through the document picker. file.Path.LocalPath is unreliable — always use OpenReadAsync/OpenWriteAsync. Details: avalonia-services.
  • Android runtime permissions: declare in AndroidManifest.xml (<uses-permission>), request via Android APIs from the activity; AvaloniaActivity.RequestPermissionsResult / ActivityResult callbacks (Action<...> properties) can receive results; IActivityResultHandler exists for this.
  • iOS: add usage descriptions (NSCameraUsageDescription, etc.) to Info.plist.

Page-based navigation (12.0+)

12.0 adds Page, ContentPage, DrawerPage, CarouselPage and related page types for mobile-style navigation (page lifecycle events fire after transitions complete). Not in 11.x — there use a ContentControl + ViewModel navigation. See avalonia-controls / avalonia-mvvm and the Avalonia docs for the page API; the dotnet template can scaffold a page-hosted main view. Wire TopLevel.BackRequested to the page stack.

Common Mistakes

  • Android 12.x with AvaloniaMainActivity<TApp> or ISingleViewApplicationLifetime — use non-generic AvaloniaMainActivity + [Application] AvaloniaAndroidApplication<TApp> + IActivityApplicationLifetime.MainViewFactory.
  • Overriding CustomizeAppBuilder on the activity (12.x) — removed; put it on the Application class.
  • Missing [Application] attribute on the AvaloniaAndroidApplication<TApp> subclass — app never initializes.
  • Wrong TFM — 12.x mobile heads need net10.0-android/net10.0-ios.
  • DisplayEdgeToEdge / ShowInputPanel / IActivatableApplicationLifetime — removed in 12; use DisplayEdgeToEdgePreference, InputPaneActivationRequested, TryGetFeature<IActivatableLifetime>().
  • Content under notch/status bar after enabling edge-to-edge — apply SafeAreaPadding (and re-apply on SafeAreaChanged).
  • Keyboard covers inputs — listen to InputPane.StateChanged, pad/scroll by EndRect.Height.
  • Accessing TopLevel.InsetsManager/InputPane too early — null before attachment; use Loaded/OnAttachedToVisualTree.
  • Forgetting e.Handled = true on back handling — app exits instead of navigating back.
  • Using PlatformFeedback on 12.0 — 12.1+ only; custom controls default to FeedbackType.None.
  • Assuming selection on press for touch — 12.x selects on release.
  • Using file paths from pickers on mobile — use stream APIs.
  • Removing ConfigChanges.UiMode/Orientation/ScreenSize — activity restarts on rotate/theme change and view state is lost.
  • Reading AvaloniaAppDelegate.Window on iOS 12 — null; scene delegate owns the window.

Sources

Frequently asked questions

What does the Avalonia Mobile AI skill do?

Use when building or fixing the Android or iOS (and Mac Catalyst) app side of an Avalonia app — project heads and startup per version (AvaloniaAndroidApplication, AvaloniaMainActivity, AvaloniaAppDelegate, IActivityApplicationLifetime vs ISingleViewApplicationLifetime), safe areas/edge-to-edge (IInsetsManager), soft keyboard (IInputPane), back button, orientation, app activation/background, haptics (PlatformFeedback), touch behavior, and mobile storage/launcher. For packaging/signing see avalonia-deployment.

Why use Avalonia Mobile on TypingMind?

Because you install it once and use it with any model. Avalonia Mobile is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Avalonia Mobile in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/linuxdevel/Avalonia-skills/tree/main/skills/avalonia/avalonia-mobile. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Avalonia Mobile?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Avalonia Mobile?

As many as you like. As long as a model supports skills, you can use Avalonia Mobile with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Avalonia Mobile AI skill free?

Yes. It is published on GitHub by linuxdevel under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇