# .NET MAUI & C# Android Closed Testing Playbook: AAB Signing, ILLink Trimming & 16 KB NDK

> Compile signed .NET 9 MAUI and Blazor Hybrid Android App Bundles (.aab) with RunAOTCompilation, R8/ILLink trimming safety, 16 KB runtime alignment, and 14-day Play Console testing.

- **Canonical URL**: https://gootester.com/frameworks/dotnet-maui
- **Config File**: MyApp.csproj & Platforms/Android/AndroidManifest.xml
- **Build Command**: `dotnet publish -f net9.0-android -c Release -p:AndroidPackageFormat=aab -p:AndroidKeyStore=true`

```xml
<PropertyGroup Condition="$(TargetFramework.Contains('-android')) and '$(Configuration)' == 'Release'">
  <ApplicationId>com.example.mauiapp</ApplicationId>
  <ApplicationDisplayVersion>1.0.2</ApplicationDisplayVersion>
  <ApplicationVersion>3</ApplicationVersion>
  <SupportedOSPlatformVersion>24.0</SupportedOSPlatformVersion>
  <TargetPlatformVersion>35.0</TargetPlatformVersion>
  <AndroidPackageFormat>aab</AndroidPackageFormat>
  <RunAOTCompilation>true</RunAOTCompilation>
  <EnableLLVM>true</EnableLLVM>
  <PublishTrimmed>true</PublishTrimmed>
  <AndroidLinkTool>r8</AndroidLinkTool>
  <AndroidKeyStore>true</AndroidKeyStore>
</PropertyGroup>
```

## Critical Play Console Gotchas
1. **ILLink trimming stripping System.Text.Json or XAML bindings in Release**: Debug MAUI builds disable IL trimming, whereas dotnet publish -c Release activates PublishTrimmed=true and removes unreferenced C# reflection properties automatically. Use C# source-generated JsonSerializerContext classes and compiled XAML bindings (x:DataType) to prevent silent Release crashes.
2. **Targeting net8.0-android prior to 16 KB Mono runtime updates**: Early .NET 8 Android workloads packaged libmonosgen-2.0.so and libxa-internal-api.so with 4 KB ELF page alignment, triggering immediate Play Console 16 KB compatibility alerts. Migrate to net9.0-android with updated workloads before submitting your bundle to closed testing.
3. **Leaving ApplicationId set to com.companyname.* template default**: Visual Studio and dotnet new maui project templates set <ApplicationId>com.companyname.appname</ApplicationId> inside your .csproj file by default. Google Play Console either blocks com.companyname namespaces outright or locks your listing into an unprofessional permanent package identifier.
4. **Fast Deployment assembly loading breaking local Release verification**: Visual Studio's EmbedAssembliesIntoApk=false debug optimization deploys loose DLL assemblies over ADB and hides real packaging errors. Always install and test your Release .aab locally via bundletool on a physical Android phone before inviting closed testers.

## Hardening `.csproj` Release Properties, ILLink Trimming & Startup AOT

Developers building cross-platform mobile apps in C# with .NET 9 MAUI (or .NET MAUI Blazor Hybrid) experience one of the sharpest Debug-versus-Release divergence curves in mobile engineering. In `Debug` configuration, Mono runs with JIT interpretation, `PublishTrimmed` is off, and R8 Java shrinking is bypassed. The moment you run `dotnet publish -f net9.0-android -c Release -p:AndroidPackageFormat=aab`, both the .NET Intermediate Language Linker (`ILLink`) and Android's `r8` shrinker prune types aggressively while Mono Ahead-of-Time (`RunAOTCompilation=true` with startup profiling) compiles hot C# assemblies into native `.so` modules.
To prevent first-launch `MissingMethodException` or blank CollectionView templates on closed testers' phones, adopt three .NET 9 MAUI practices before cutting `ApplicationVersion` `1`: annotate every XAML page and `DataTemplate` with `x:DataType` compiled bindings instead of string reflection bindings, replace runtime `JsonSerializer.Deserialize<T>()` reflection with `[JsonSerializable(typeof(T))]` source-generated contexts, and inspect trimmer warnings (`IL2026`, `IL2087`) during `dotnet publish` instead of suppressing them.
Pass signing secrets strictly through CLI or GitHub Actions environment parameters (`-p:AndroidSigningKeyStore=$KEYSTORE_PATH -p:AndroidSigningKeyAlias=upload -p:AndroidSigningKeyPass=$KEY_PASS -p:AndroidSigningStorePass=$STORE_PASS`) so keystore binaries and passwords never enter source control.

## Validating Cold-Start Latency, SQLite-net & Blazor Hybrid WebViews

Cold-start Time to Initial Display (TTID) and startup ANRs deserve special focus on .NET MAUI Android apps. Initializing heavy DI containers (`MauiProgram.CreateMauiApp()`), running synchronous `sqlite-net-pcl` or EF Core migrations on the UI thread inside `App.xaml.cs`, or loading large uncompressed splash SVGs can push cold boot past 4–5 seconds on budget Snapdragon and MediaTek hardware. Defer database migrations and API token refresh calls to asynchronous background initialization after the initial shell frame renders.
For MAUI Blazor Hybrid apps (`BlazorWebView`), remember that Android renders Razor components inside the system Chromium WebView hosted at `https://0.0.0.0/` (or `appdir`). Verify Android 15/16 edge-to-edge safe-area padding across both native MAUI Shell bars and inner Blazor CSS layouts. GOOtester's Standard ($12, 15 human testers / 16 days) and Premium ($20, 25 human testers / 24 days) plans execute separate automated physical-device ARM64 ADB QA runs (`dumpsys meminfo` RAM PSS, `dumpsys gfxinfo` frame jank, cold-start crash/ANR telemetry) without ever counting automated ADB runs as human testers.
Replace legacy `CollectionView` nested `StackLayout` templates with flat `Grid` definitions and recycling `ItemSizingStrategy="MeasureFirstItem"` where uniform row heights apply, preventing layout thrashing and dropped frames on 60 Hz and 120 Hz Android screens.

## Coordinating 14-Day Closed Testing & Multi-Version `.aab` Updates

Personal Google Play Console accounts must maintain at least 12 opted-in human testers continuously for 14 consecutive days on a Closed Testing track. Once your initial `.aab` passes Play Console track review and you link `testers@gootester.com` under Closed Testing -> Testers -> Google Groups (and publish any held changes in Publishing Overview), GOOtester verifies your opt-in URL and starts your local service clock.
Increment `<ApplicationVersion>` (`1` -> `2` -> `3`) in `MyApp.csproj` to publish two targeted bugfix bundles during your 14-to-24-day campaign, syncing version metadata via GOOtester's `/api/v1/ci/release` webhook (`gt_live_example_token_12345`). While Google Play alone decides Production Access, demonstrating multi-release C# stability improvements alongside steady human tester retention provides verifiable engineering rigor.
Wire `AppDomain.CurrentDomain.UnhandledException` and `TaskScheduler.UnobservedTaskException` crash breadcrumbing to Sentry or Firebase Crashlytics during closed testing so asynchronous `Task` faults on OEM Android variants surface immediately with full C# stack frames.
