Skip to content

aapt2.exe crashes with access violation (BEX64) in daemon mode when spawned by Aapt2Compile — hangs build indefinitely #12662

Description

@jflietstra

Android framework version

net10.0-android

Affected platform version

Visual Studio 2026 18.9.2, .NET SDK 10.0.400, Microsoft.Android.Sdk.Windows 36.1.69 (aapt2 2.20-13193326), Windows 11 Pro 10.0.26200.2 (not Insider), Dell XPS 16 / Intel Core i9

Description

aapt2.exe crashes with STATUS_ACCESS_VIOLATION (0xc0000005) every single time it is invoked in daemon mode by the Aapt2Compile/_CompileResources MSBuild target, on one specific (otherwise healthy) machine. The build appears to "hang" forever because the MSBuild task never notices the child process died, and just waits for a response that never comes — no error is ever surfaced anywhere in the MSBuild output.

Running the exact same aapt2.exe daemon command manually, interactively, in a normal console window (i.e. NOT spawned by MSBuild/System.Diagnostics.Process with redirected stdio and CreateNoWindow=true) works perfectly — it prints Ready and sits waiting for input, no crash. aapt2.exe version also works fine either way, which rules out a missing dependency (e.g. VC++ runtime) since all statically-declared DLL imports resolve correctly.

Crash details (Event Viewer / WER):

Faulting application name: aapt2.exe, version: 0.0.0.0, time stamp: 0x1f2830d0
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0xc0000005
Faulting application path: C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\36.1.69\tools\aapt2.exe

Event Name: BEX64
P7: PCH_xx_FROM_ntdll+0x0000000000161914   (consistent offset across 3 independent runs, only the PCH_xx prefix varies)
P8: c0000005

Report.wer's LoadedModule list at crash time contains ONLY aapt2.exe plus stock Windows system DLLs (ntdll, KERNEL32, KERNELBASE, ucrtbase, SHELL32, msvcp_win, USER32, win32u, GDI32, gdi32full, IMM32, shcore, advapi32, msvcrt, sechost, RPCRT4, CRYPTBASE, bcryptPrimitives) — nothing from any antivirus/EDR/overlay software is loaded, which rules out third-party hooking as the cause.

What was ruled out (none of these changed the outcome):

  • Windows Defender exclusions for the project folder, Android SDK folder, .nuget, .gradle, .android
  • Malwarebytes real-time protection fully disabled
  • NVIDIA app/GeForce Experience overlay disabled
  • Full Clean Boot (msconfig: all non-Microsoft services/startup items disabled, machine rebooted) — crash still 100% reproducible at the identical ntdll offset
  • Windows Security → Exploit Protection → Program settings inspected — only stock Microsoft default entries present, nothing custom targets dotnet.exe/MSBuild.exe/devenv.exe/aapt2.exe
  • dotnet workload repair (full repair of android, ios, maccatalyst, maui-windows) — completed successfully, crash persists identically
  • Removing a newly-added MauiImage resource from the project — crash still occurs on the remaining stock app-icon/splash resources
  • Not enrolled in the Windows Insider Program
  • Killed orphaned aapt2.exe processes from a previously-cancelled build + rebooted before retrying — no change
  • Reproduces identically via plain dotnet build -f net10.0-android from the command line AND via the Visual Studio 2026 IDE — not VS-IDE-specific

Further narrowing:

  • Setting <Aapt2DaemonMaxInstanceCount>1</Aapt2DaemonMaxInstanceCount> in the .csproj (default allows up to 6 parallel daemon instances) delayed the crash — the build appeared to progress actively for ~70 to ~330 seconds before hitting the identical crash — but did not prevent it.
  • Manual interactive aapt2.exe daemon (own console, not spawned by MSBuild) never crashes, which points at something specific to how Aapt2Daemon launches the process (CreateNoWindow=true, RedirectStandardInput/Output/Error=true, UseShellExecute=false) rather than a bug that triggers in daemon mode unconditionally.

Happy to attach the full .dmp file (available locally under C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_aapt2.exe_...) or run further diagnostics on request.

As a secondary ask: even a fix that makes a crashed daemon child surface as a build error instead of hanging forever would make this whole class of problem far easier to diagnose.

Steps to Reproduce

  1. .NET MAUI app project, <TargetFrameworks>net10.0-android</TargetFrameworks>, Microsoft.Maui.Controls 10.0.90.
  2. Run dotnet build -f net10.0-android -v detailed (reproduces identically via Visual Studio 2026 Build/Rebuild).
  3. Build proceeds normally through NuGet restore, Clean, and dozens of MSBuild targets.
  4. Build reaches _CompileResources (invokes the Aapt2Compile task).
  5. aapt2.exe is spawned in daemon mode and crashes near-instantly with an access violation (see Event Viewer output above).
  6. The MSBuild task never detects the child process death and blocks forever — build must be cancelled manually, no error is ever printed.

Did you find any workaround?

No true fix found. Setting <Aapt2DaemonMaxInstanceCount>1</Aapt2DaemonMaxInstanceCount> in the .csproj delays the crash (build runs for ~1-5 minutes before hitting it) but does not prevent it.

Relevant log output

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: App+Library BuildIssues when building Library projects or Application projects.need-infoIssues that need more information from the author.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions