Skip to content

Include NativeAOT debug symbols in Android App Bundles - #13211

Open
simonrozsival with Copilot wants to merge 4 commits into
mainfrom
copilot/auto-include-nativeaot-debug-symbols
Open

simonrozsival with Copilot wants to merge 4 commits into
mainfrom
copilot/auto-include-nativeaot-debug-symbols

Conversation

Copilot AI commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Context: #13206
Context: #8903 (comment)

Release NativeAOT Android App Bundles currently omit the generated app-library debug symbols. Google Play consequently warns that native debug symbols are missing and cannot use them to symbolicate crashes and ANRs.

Include the generated symbols for every packaged ABI under:

BUNDLE-METADATA/com.android.tools.build.debugsymbols/<ABI>/lib<TargetName>.so.dbg

The NativeAOT publish item now carries both the ABI and corresponding .dbg.so path into the outer Android build. _PrepareBuildApk converts that information into AndroidAppBundleMetaDataFile entries for Release NativeAOT App Bundles. This is automatic; applications do not need to list ABI-specific paths or add a custom target.

BuildAppBundle quotes ordinary metadata paths through CommandLineBuilder.AppendSwitchIfNotNull(), preserving values containing ASCII spaces. Java on Windows can still replace non-ASCII command-line characters before BundleTool sees them, so metadata arguments containing Unicode are staged under temporary ASCII source and archive paths. After BundleTool creates the AAB, the task restores the exact Unicode BUNDLE-METADATA entry names before signing. This preserves the expected lib<TargetName>.so.dbg filename for Japanese project names and Unicode whitespace without relying on Java launcher argument-file encoding.

The symbols are not added as separate _BuildApkEmbed timestamp inputs. NativeAOT linking can update the .dbg.so after the prior bundle output while rebuilding otherwise unchanged inputs; treating it as an independent packaging input caused _BuildApkEmbed and _Sign to rerun on no-change builds. The existing packaging inputs already represent the native application output.

The multi-ABI test builds a Release NativeAOT AAB from a project named テスト Me, verifies the expected Unicode metadata entry for each ABI, and confirms that every symbol file has the same ELF build ID as its bundled application library. A task-level test also verifies that BundleTool receives only ASCII metadata arguments and that the original Unicode archive path is restored.

Validation:

  • make prepare && make leeroy — passed
  • make all — passed
  • ./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll --filter "FullyQualifiedName~BuildAppBundleTests" — passed, 1 test
  • ./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll --filter "Name~BuildNativeAotAppBundleIncludesDebugSymbols" — passed, 1 test
  • ./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll --filter "Name~CheckProjectWithSpaceInNameWorks|Name~SmokeTestBuildWithSpecialCharacters" — passed, 16 tests

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Copilot AI changed the title [WIP] Add automatic inclusion of NativeAOT debug symbols in Android App Bundles Include NativeAOT debug symbols in Android App Bundles Oct 20, 2026
Copilot AI requested a review from simonrozsival October 20, 2026 08:39
Quote bundle metadata arguments containing spaces and avoid making NativeAOT debug symbols an independent packaging input that invalidates no-change builds.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7f84d009-eadb-41b2-ab01-438d68adb424
Stage non-ASCII BundleTool metadata arguments under temporary ASCII paths, then restore their exact archive names before signing the app bundle.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7f84d009-eadb-41b2-ab01-438d68adb424
@simonrozsival
simonrozsival marked this pull request as ready for review November 5, 2026 16:38
Copilot AI balanced review requested due to automatic review settings November 5, 2026 16:38
@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Nov 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Rebuilds can package stale debug symbols with mismatched build IDs, while metadata staging remains vulnerable to Unicode temporary paths and excessive memory use for large symbol files.

3 open issues
What changed in this PR

Adds automatic NativeAOT debug-symbol packaging to Release Android App Bundles, addressing #13206 so Google Play can use symbols for native crash reports.

Changes:

  • Carries per-ABI symbol paths into bundle metadata.
  • Quotes metadata arguments and stages Unicode paths before restoring their original archive names.
  • Adds task-level Unicode coverage and a multi-ABI test checking symbol inclusion and matching ELF build IDs.
File Description
src/​Xamarin.Android.Build.Tasks/​Xamarin.Android.Common.targets Adds NativeAOT symbols to Release bundle metadata.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​BuildAppBundleTests.cs Tests Unicode metadata staging and filename restoration.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​NativeAotBuildTests.cs Verifies multi-ABI symbol entries and matching build IDs.
src/​Xamarin.Android.Build.Tasks/​Tasks/​BuildAppBundle.cs Quotes metadata arguments and restores staged Unicode entries.
src/​Xamarin.Android.Build.Tasks/​Microsoft.Android.Sdk/​targets/​Microsoft.Android.Sdk.NativeAOT.targets Publishes ABI and debug-symbol path metadata.

Review effort: Balanced

Condition=" Exists('$(_AndroidNativeAotSharedLibrary)') or '$(_AndroidR8RuntimeRemappingEnabled)' == 'true' ">
<RelativePath>$(_AndroidNativeAotSharedLibraryName)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<_AndroidNativeAotDebugSymbols>$([System.IO.Path]::ChangeExtension('$(_AndroidNativeAotSharedLibrary)', '.dbg.so'))</_AndroidNativeAotDebugSymbols>
bundleToolMetaDataFiles.Add (file.ItemSpec);
continue;
}
var sourcePath = Path.GetTempFileName ();
Comment on lines +196 to +200
var entry = bundle.CreateEntry (file.ArchivePath, CompressionLevel.Optimal);
entry.LastWriteTime = temporaryEntry.LastWriteTime;
using (var input = temporaryEntry.Open ())
using (var output = entry.Open ())
input.CopyTo (output);

This branch has not been deployed

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

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatically include NativeAOT debug symbols in Android App Bundles for Google Play

3 participants