|
1 | 1 | <Project> |
2 | 2 | <PropertyGroup> |
3 | 3 | <SupportedOSPlatformVersion>33.0</SupportedOSPlatformVersion> |
4 | | - <RuntimeIdentifiers>android-x86;android-arm;android-arm64</RuntimeIdentifiers> |
| 4 | + <!-- arm64-v8a covers 99%+ of modern Android devices. |
| 5 | + armeabi-v7a is kept for older 32-bit devices. |
| 6 | + x86 removed — only used by legacy emulators; modern x86_64 emulators |
| 7 | + run arm64 binaries via native translation (no dedicated x86 build needed). --> |
| 8 | + <RuntimeIdentifiers>android-arm;android-arm64</RuntimeIdentifiers> |
5 | 9 | <AndroidPackageFormat>apk</AndroidPackageFormat> |
| 10 | + <!-- CJK and Mideast encodings are needed for song metadata display. |
| 11 | + Rare covers supplementary Unicode blocks. West is the default Latin set. --> |
6 | 12 | <MandroidI18n>CJK;Mideast;Rare;West;Other;</MandroidI18n> |
7 | 13 | <AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidMessageHandler</AndroidHttpClientHandlerType> |
8 | 14 | <!-- NullabilityInfoContextSupport is disabled by default for Android --> |
9 | 15 | <NullabilityInfoContextSupport>true</NullabilityInfoContextSupport> |
10 | 16 | <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk> |
11 | | - <!-- Suppress XA0141 page-size warnings during build. The actual .so files are patched |
12 | | - to 16 KB alignment by build/PatchElfPageSize.targets, but the SDK check runs before |
13 | | - the patch in some build orderings. This suppression is harmless since we do fix them. --> |
| 17 | + <!-- Suppress XA0141 page-size warnings. ELF patching is disabled for all configurations |
| 18 | + (see PatchElfPageSizeEnabled below) to prevent APK signature corruption. |
| 19 | + The XA0141 warning is therefore expected and harmless. |
| 20 | + AndroidPageSize16KBCompatibilityCheck=false should suppress the check, but Android SDK |
| 21 | + 36.1.53 still emits XA0141 in some build orderings, so we also add it to NoWarn. --> |
14 | 22 | <AndroidPageSize16KBCompatibilityCheck>false</AndroidPageSize16KBCompatibilityCheck> |
| 23 | + <NoWarn>$(NoWarn);XA0141</NoWarn> |
| 24 | + <!-- Disable ELF alignment patching for ALL configurations. |
| 25 | + The custom PatchElfPageSize task can run concurrently with the Android packaging step |
| 26 | + because MSBuild's BeforeTargets="Build" fires for every ABI sub-build, which often |
| 27 | + overlaps with the main APK assembly pass. Patching .so files in the NuGet cache while |
| 28 | + they are being read and packed into the APK can corrupt the ZIP/signing structures, |
| 29 | + producing an APK with a null certificate array (INSTALL_PARSE_FAILED_NO_CERTIFICATES). |
| 30 | + TODO: Re-enable once ppy.Veldrid.SPIRV ships 16 KB-aligned native libraries so no |
| 31 | + patching is needed at all, or once the build targets are re-sequenced so |
| 32 | + patching always completes before packaging starts. --> |
| 33 | + <PatchElfPageSizeEnabled>false</PatchElfPageSizeEnabled> |
15 | 34 | </PropertyGroup> |
16 | 35 |
|
17 | 36 | <!-- Patch NuGet-provided .so files that ship with 4 KB ELF alignment to 16 KB. |
|
26 | 45 | <RunAOTCompilation>true</RunAOTCompilation> |
27 | 46 | <AndroidEnableProfiledAot>true</AndroidEnableProfiledAot> |
28 | 47 | <SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings> |
29 | | - <!-- Disable ELF patching in Release to prevent signature corruption --> |
30 | | - <PatchElfPageSizeEnabled>false</PatchElfPageSizeEnabled> |
31 | 48 | <PublishTrimmed>true</PublishTrimmed> |
32 | 49 | <TrimMode>partial</TrimMode> |
| 50 | + <!-- Strip IL bodies from AOT-compiled assemblies. The runtime uses the native .so code |
| 51 | + instead, and IL is only kept for non-AOT methods. This can save 20-30 MB. --> |
| 52 | + <AndroidStripILAfterAOT>true</AndroidStripILAfterAOT> |
| 53 | + <!-- Compress managed assemblies inside the APK (LZ4). Android extracts them on first run |
| 54 | + but the download/APK size is significantly smaller. --> |
| 55 | + <AndroidEnableAssemblyCompression>true</AndroidEnableAssemblyCompression> |
| 56 | + <!-- Don't ship PDB files in the APK — they add ~15-20 MB. |
| 57 | + Stack traces still work via embedded metadata. --> |
| 58 | + <DebugType>none</DebugType> |
| 59 | + <DebugSymbols>false</DebugSymbols> |
33 | 60 | </PropertyGroup> |
34 | 61 |
|
35 | 62 | <ItemGroup Condition="'$(Configuration)' == 'Release'"> |
|
56 | 83 | </PropertyGroup> |
57 | 84 |
|
58 | 85 | <!-- Fix for .NET 10 Android AOT misclassifying non-managed assets in runtime pack. |
59 | | - This is critical for Android 16 (API 36) which has stricter manifest/parsing rules. |
60 | | - We hook into multiple stages to ensure all native assets (including BASS and native bridge) |
61 | | - are correctly identified before the optimization/signing phases. --> |
62 | | - <Target Name="FixRuntimePackAssetTypes" AfterTargets="ResolveRuntimePackAssets;ComputeFilesToPublish;ComputeResolvedFilesToPublishList"> |
| 86 | + This is critical for Android 16 (API 36) Release/AOT builds where the linker expects |
| 87 | + all non-managed assets to be marked as native before the optimization/signing phases. |
| 88 | + Scoped to Release only — running this during Debug builds can interfere with how the |
| 89 | + Android SDK classifies signing-related items, leading to APKs with null certificate |
| 90 | + arrays (INSTALL_PARSE_FAILED_NO_CERTIFICATES). --> |
| 91 | + <Target Name="FixRuntimePackAssetTypes" AfterTargets="ResolveRuntimePackAssets;ComputeFilesToPublish;ComputeResolvedFilesToPublishList" |
| 92 | + Condition="'$(Configuration)' == 'Release'"> |
63 | 93 | <ItemGroup> |
64 | 94 | <RuntimePackAsset Update="@(RuntimePackAsset)" Condition="'%(Extension)' != '.dll' AND '%(Extension)' != '.pdb'"> |
65 | 95 | <AssetType>native</AssetType> |
|
0 commit comments