Description
Description
We noticed this here:
We use System.IO.Compression.ZipArchive to create Android .apk
files (and other archives).
When signing an .apk
with Android's zipalign
tool, it reports:
01-30 21:38:27.669 38611 159726 W zip : WARNING: header mismatch
However, if I inspect the actual file, some tools are ok with it:
> 7z t D:\Downloads\com.companyname.DotNetNewandroid.apk
7-Zip 24.09 (x64) : Copyright (c) 1999-2024 Igor Pavlov : 2024-11-29
Scanning the drive for archives:
1 file, 7069900 bytes (6905 KiB)
Testing archive: D:\Downloads\com.companyname.DotNetNewandroid.apk
--
Path = D:\Downloads\com.companyname.DotNetNewandroid.apk
Type = zip
Physical Size = 7069900
Everything is Ok
Files: 46
Size: 20333467
Compressed: 7069900
So, then we tried:
$ zipdetails com.companyname.DotNetNewandroid.apk
...
#
# ERROR: Found 1 Field Mismatch for Filename 'AndroidManifest.xml'
#
# --------------------------------------------------------------------------------------
# | Field Name | Central Offset | Central Value | Local Offset | Local Value |
# --------------------------------------------------------------------------------------
# | Extract Zip Spec | 0x6BD1E2 (7066082) | 0x14 (20) 2.0 | 0x7 (7) | 0x0 (0) 0.0 |
# --------------------------------------------------------------------------------------
#
# ERROR: Found 1 Field Mismatch for Filename 'res/layout/activity_main.xml'
#
# --------------------------------------------------------------------------------------
# | Field Name | Central Offset | Central Value | Local Offset | Local Value |
# --------------------------------------------------------------------------------------
# | Extract Zip Spec | 0x6BD223 (7066147) | 0x14 (20) 2.0 | 0x460 (1120) | 0x0 (0) 0.0 |
# --------------------------------------------------------------------------------------
#
# ERROR: Found 1 Field Mismatch for Filename 'res/layout/layout.xml'
#
# --------------------------------------------------------------------------------------
# | Field Name | Central Offset | Central Value | Local Offset | Local Value |
# --------------------------------------------------------------------------------------
# | Extract Zip Spec | 0x6BD26D (7066221) | 0x14 (20) 2.0 | 0x5C0 (1472) | 0x0 (0) 0.0 |
# --------------------------------------------------------------------------------------
#
# ERROR: Found 1 Field Mismatch for Filename 'res/mipmap-anydpi-v26/appicon.xml'
#
# ----------------------------------------------------------------------------------------
# | Field Name | Central Offset | Central Value | Local Offset | Local Value |
# ----------------------------------------------------------------------------------------
# | Extract Zip Spec | 0x6BD7A4 (7067556) | 0x14 (20) 2.0 | 0x779C (30620) | 0x0 (0) 0.0 |
# ----------------------------------------------------------------------------------------
#
# ERROR: Found 1 Field Mismatch for Filename 'res/mipmap-anydpi-v26/appicon_round.xml'
#
# ----------------------------------------------------------------------------------------
# | Field Name | Central Offset | Central Value | Local Offset | Local Value |
# ----------------------------------------------------------------------------------------
# | Extract Zip Spec | 0x6BD7F3 (7067635) | 0x14 (20) 2.0 | 0x78B0 (30896) | 0x0 (0) 0.0 |
# ----------------------------------------------------------------------------------------
#
# Error Count: 5
Full output: https://gist.github.com/grendello/3007335dba59383ac7782311d262e844
Reproduction Steps
dotnet new android
dotnet build
Xamarin.Android.Common.targets(2547,2): error ANDZA0000: 01-30 21:38:27.669 38611 159726 W zip : WARNING: header mismatch
Expected behavior
ZipArchive
produces files that do not cause Android tooling to produce errors.
Actual behavior
ZipArchive
produces files that cause Android tooling to produce errors.
Regression?
Yes
Known Workarounds
We are attempting a flag we have $(_AndroidUseLibZipSharp)=true
, that will fall back to an open-source zip library we used to use.
Configuration
.NET SDK: 10.0.100-preview.1.25079.13
.NET runtime: 10.0.0-preview.1.25078.5
Archive: com.companyname.DotNetNewandroid.apk.zip
Other information
No response