Skip to content

Commit

Permalink
[Xamarin.Android.Build.Tasks] Fix Android Version Code for Release bu…
Browse files Browse the repository at this point in the history
…ilds

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`.
  • Loading branch information
dellis1972 committed Mar 15, 2023
1 parent 0e4c29a commit ef5a3bb
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,8 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
<_AndroidPackage>$(ApplicationId)</_AndroidPackage>
<_ApplicationLabel>$(ApplicationTitle)</_ApplicationLabel>
<_AndroidVersionName>$(ApplicationDisplayVersion)</_AndroidVersionName>
<_AndroidVersionCode Condition=" '$(AndroidCreatePackagePerAbi)' != 'true' ">$(ApplicationVersion)</_AndroidVersionCode>
<_AndroidVersionCode Condition=" '$(AndroidCreatePackagePerAbi)' == 'true' And '$(ApplicationVersion)' != '' ">$(ApplicationVersion)</_AndroidVersionCode>
<_AndroidVersionCode Condition=" '$(AndroidCreatePackagePerAbi)' != 'true' And '$(_AndroidVersionCode)' == '' ">$(ApplicationVersion)</_AndroidVersionCode>
</PropertyGroup>
<AndroidError Code="XA1018"
ResourceName="XA1018"
Expand Down

0 comments on commit ef5a3bb

Please sign in to comment.