Versioning my Maui Android App

Copper Contributor

Previously the way to define version code for Android in Maui .csproj file was like this:

 

 

 

<!-- Versions -->
<ApplicationVersion>3.1.2</ApplicationVersion>
<AndroidVersionCode>3</AndroidVersionCode>

 

 

 

With the new release of Visual Studio Preview, this has changed to:

 

 

 

<ApplicationVersion>3</ApplicationVersion>

 

 

 

It works, from Visual Studio, I can bundle a new .aab package (see image below). We see the version code is defined to 3. Unfortunately the version is defined to 1.0.0 and I don't know how to change this.

 

Bronzato_0-1638270460170.png

 

...when imported on the Google Play Console, it look like this:

 

Bronzato_2-1638270667736.png

 

Unfortunately, when imported I only see the versionCode 3 (which is defined in the .csproj file as ApplicationVersion). What about the versionName (in parentheses) ? Nothing is planned in the .csproj file ? When imported on the Google Play Console, I don't want to have  3 (1.0.0) but I want 3 (3.1.2)...

 

https://developer.android.com/studio/publish/versioning

 

versionCode — A positive integer used as an internal version number.

versionName — A string used as the version number shown to users.

 

 

7 Replies

You should be able to set:

 

<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>

 



or manually set in your androidmanifest.xml

 

Checkout https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/OneDotNetSingleProject.md

@JamesMontemagno thanks for your answer. By adding the code you suggest in my csproj file gives me errors.

 

Bronzato_3-1638636659047.png

 

As soon as I remove this code, the errors disappeared.

Manually set inside my AndroidManifest.xml do the trick but I would have liked to adapt my csproj file.

 

Bronzato_1-1638636359088.png

Bronzato_2-1638636605253.png

 

I'm using Visual Studio Professional 2022 - Preview Version 17.1.0 Preview 1.1

@Bronzato Hey, try this: 

<AndroidManifestApplicationName>Your App Name</AndroidManifestApplicationName>
<AndroidManifestApplicationPackageName>com.companyname.your.app.name</AndroidManifestApplicationPackageName>
<AndroidManifestApplicationVersionNumber>4</AndroidManifestApplicationVersionNumber>
<AndroidManifestApplicationVersionName>4.2.1</AndroidManifestApplicationVersionName>

EDIT: This doesn't work, use the normal way of versioning as @JamesMontemagno wrote below: <ApplicationDisplayVersion>4.2.1</ApplicationDisplayVersion>
<ApplicationVersion>4</ApplicationVersion>

In the most recent release candidate the team added back:

```
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
```

This will set your versions correct in .NET MAUI

Hi @Bronzato,

Thanks for posting your issue here.

However this platform is used for how-to discussions and sharing best practices for building any app with .NET.Since your issue is a technical question, welcome to post it in Microsoft Q&A forum, the support team and communities on Microsoft Q&A will help you for any technical questions.
Besides, it will be appreciated if you can share it here once you post this technical question Microsoft Q&A.
Best Regards,
Lan Huang

Hi James, i was wondering how I can have different versions between iOS and Android? I had removed the <ApplicationDisplayVersion>1.0.0</ApplicationDisplayVersion> and <ApplicationVersion>1</ApplicationVersion> from the csproj file, and specified a correct value (3.0.0) in the AndroidManifest.xml and Info.plist, but the version still is 1.0.0 on the AppVersion class

@JamesMontemagno Thanks.  I'm trying to Bump versions in VSTS and getting this error

##[error]unable to find the matched key.

 

I've enabled the setting that prints the "before" version of the manifest and  both android versions are missing, so I'm guessing there is nothing to 'bump'.  I have not changed anything significant from the default maui template.  Any ideas?