Repository navigation
Include NativeAOT debug symbols in Android App Bundles - #13211
Open
simonrozsival with Copilot wants to merge 4 commits into
Open
simonrozsival with Copilot wants to merge 4 commits into
simonrozsival with Copilot wants to merge 4 commits into
Conversation
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
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
marked this pull request as ready for review
November 5, 2026 16:38
Contributor
There was a problem hiding this comment.
🟡 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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:
The NativeAOT publish item now carries both the ABI and corresponding
.dbg.sopath into the outer Android build._PrepareBuildApkconverts that information intoAndroidAppBundleMetaDataFileentries for Release NativeAOT App Bundles. This is automatic; applications do not need to list ABI-specific paths or add a custom target.BuildAppBundlequotes ordinary metadata paths throughCommandLineBuilder.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 UnicodeBUNDLE-METADATAentry names before signing. This preserves the expectedlib<TargetName>.so.dbgfilename for Japanese project names and Unicode whitespace without relying on Java launcher argument-file encoding.The symbols are not added as separate
_BuildApkEmbedtimestamp inputs. NativeAOT linking can update the.dbg.soafter the prior bundle output while rebuilding otherwise unchanged inputs; treating it as an independent packaging input caused_BuildApkEmbedand_Signto 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— passedmake 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