Recursive AI

Create an Android App Bundle (.aab) for Google Play in C#

OneApp is a free, open-source framework for apps in .NET whose UI is HTML and CSS, drawn natively with no web view on Windows, macOS, Linux, iOS and Android, and run in the browser, from Recursive AI. MIT or Apache-2.0.

Build a bundle for Play on Linux x64 with the Android SDK and NDK.

Terminal
dotnet tool install -g RecursiveAI.OneApp.Cli

Requires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.

  1. Install Android SDK Build Tools, Platform Tools, the API 36 SDK Platform, and the NDK. The OneApp 1.2.1 Android tools docs specify a Linux x86-64 NDK toolchain for linking, so build the bundle on Linux x64, not natively on Windows or macOS.
  2. Set ANDROID_HOME to the SDK directory. No .NET Android workload is needed.
  3. Unzip the example and open a terminal in that folder. Install a JDK with keytool. To create upload.p12 for a new app, run the following and enter the password when prompted. If you’re updating an existing Play app, use its registered upload key instead.
Terminal
keytool -genkeypair -alias app -keyalg RSA \
  -keysize 2048 -validity 10000 \
  -storetype PKCS12 -keystore upload.p12

Set ONEAPP_ANDROID_KEYSTORE_PASSWORD to the keystore password in the shell where you package the app. Don’t check the keystore or password into source control.

Terminal
oneapp package . --format aab \
  --keystore upload.p12

Run oneapp package as shown above in the unzipped project folder. This writes TrailLog-1.0.0-android.aab. dotnet run is only for the desktop preview.

Full program

TrailLog.csproj is in the zip. It sets the target API in OneAppAndroidTargetSdk; OneApp otherwise defaults to 34. The project already references the app host (dotnet add package RecursiveAI.OneApp to add it to an existing project).

XML
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <PublishAot>true</PublishAot>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <OneAppId>org.example.traillog</OneAppId>
    <OneAppName>TrailLog</OneAppName>
    <OneAppVersion>1.0.0</OneAppVersion>
    <OneAppAndroidTargetSdk>36</OneAppAndroidTargetSdk>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="RecursiveAI.OneApp" Version="1.2.1" />
  </ItemGroup>
</Project>

The Android activity calls Program.Main. The page is inline HTML, with padding for the status and navigation bars.

C#
using OneApp;
 
public static class Program
{
    public static int Main(string[] args)
    {
        const string page = """
            <main style="padding:calc(16px + var(--safe-area-inset-top, 0px))
                                calc(16px + var(--safe-area-inset-right, 0px))
                                calc(16px + var(--safe-area-inset-bottom, 0px))
                                calc(16px + var(--safe-area-inset-left, 0px))">
              <h1>TrailLog</h1>
            </main>
            """;
        using var host = AppHost.Create(new AppOptions(page)
        {
            Title = "TrailLog",
            AppId = "org.example.traillog",
        });
        host.Run();
        return 0;
    }
}

The packaging command reported these fields in its JSON output (excerpt):

JSON
{
  "format": "aab",
  "package": "org.example.traillog",
  "versionCode": "10000",
  "abis": "arm64-v8a,x86_64",
  "signing": "release key"
}

If the tool can’t find a release keystore, it won’t create an upload-signed bundle. Supply a .p12 file and its password rather than using a debug key.

Variations

Write the bundle to a separate directory for release artifacts:

Terminal
oneapp package . --format aab \
  --keystore upload.p12 --output dist

The short answer

Use oneapp package . --format aab --keystore upload.p12 to create a release-signed Android App Bundle from a OneApp C# project. The tool builds the base module with your app manifest, resources, activity code, and native libraries for arm64-v8a and x86_64. It signs the bundle locally. Publishing is a separate step in Play Console.

What is the difference between an APK and an Android App Bundle?

An APK is an installable file. An AAB is a publishing format, not something adb install can put on a device. Google Play takes your bundle and builds APKs for each device configuration. If you just want a file to send to a tester for direct installation, build an APK. To test the splits produced from a bundle, see Android’s bundle testing guide.

Is the upload key the same as the app signing key?

With Play App Signing, you sign the .aab with your upload key. Play checks that signature, then signs the APKs it distributes with the app signing key. The APK your users install does not have to carry the certificate you used on the bundle.

What target API level does Google Play require?

Google’s target API requirements say that new phone apps and updates must target Android 16 (API 36) or higher starting August 31, 2026. OneAppAndroidTargetSdk sets what your bundle declares, not the oldest version of Android on which the app can run. When targeting API 36, keep controls clear of system bars: the example uses OneApp’s --safe-area-inset-* CSS properties for that padding. Replace org.example.traillog with your own permanent package ID before publishing, then increase the version code for each update. Targeting API 36 is not the only release requirement: because the bundle contains native code, also check Google’s 16 KB page size requirements before submitting.

All oneapp recipes