Skip to content

Commit 71563dc

Browse files
committed
[Xamarin.Android.Build.Tasks] Fix Android Version Code for Release builds
Fixes dotnet/maui#11139 Users trying to use `maui` and the new `ApplicationVersion` in conjunction with `AndroidCreatePackagePerAbi` find that the version is NOT used in the final set of apks. This is because when we use `AndroidCreatePackagePerAbi` we are totally ignoring the `ApplicationVersion` number. Instead we pick up the one from the `AndroidManifest.xml` `android:versionCode`. For maui users This is not obvious and is counter intuitive. So lets use the `ApplicationVersion` when using `AndroidCreatePackagePerAbi`. All the old code will remain in place, if the `ApplicationVersion` is not set we will still fall back to `android:versionCode` and if that is not set default to `1`.
1 parent bec42ef commit 71563dc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,8 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
595595
<_AndroidPackage>$(ApplicationId)</_AndroidPackage>
596596
<_ApplicationLabel>$(ApplicationTitle)</_ApplicationLabel>
597597
<_AndroidVersionName>$(ApplicationDisplayVersion)</_AndroidVersionName>
598-
<_AndroidVersionCode Condition=" '$(AndroidCreatePackagePerAbi)' != 'true' ">$(ApplicationVersion)</_AndroidVersionCode>
598+
<_AndroidVersionCode Condition=" '$(AndroidCreatePackagePerAbi)' == 'true' And '$(ApplicationVersion)' != '' ">$(ApplicationVersion)</_AndroidVersionCode>
599+
<_AndroidVersionCode Condition=" '$(AndroidCreatePackagePerAbi)' != 'true' And '$(_AndroidVersionCode)' == '' ">$(ApplicationVersion)</_AndroidVersionCode>
599600
</PropertyGroup>
600601
<AndroidError Code="XA1018"
601602
ResourceName="XA1018"

0 commit comments

Comments
 (0)