See how to publish your .NET MAUI app to Android in these few easy steps!
Probably when you started developing apps, you were super excited to learn the process to publish yours—this is what allows us to finally make our app visible to an audience of people!
Although the process of publishing apps is similar on different platforms, each one has its rules and processes to follow to publish them. That’s why, in this article, we are going to learn the process of publishing an app on Android from .NET MAUI. It’s super easy. Pay attention to each of the steps that we will be explaining to you in this article!
First of all, keep in mind the following terms. In the process of distribution of an Android application, two type of files are generated:
The keystore is a file that allows you to more securely store your credentials.
⚠ At the moment, .NET MAUI only allows you to do this with commands; the visual interface will be released later. All the same, learning the commands is an excellent option!
To create your keystore file, you need to do the following steps:
keytool -genkey -v -keystore myapp.keystore -alias MyAppkey -keyalg RSA -keysize 2048 -validity 10000
I will leave some definitions of the parameters that I consider more relevant from the previous command line and that you should be clear on when using.
|keystore||This is where the keystore is going to be stored.|
|keyalg (key algorithm)||You can specify an algorithm with which the encrypted data will be signed.|
|keysize||Number of bytes that are used for encryption.|
|validity||Number of days until the expiration of your certificate.|
Once executed, it will ask you for a password to continue:
Then you must fill out a set of questions:
|What is your first and last name?|
|What is the name of your organizational unit?|
|What is the name of your organization?|
|What is the name of your City or Locality?|
|What is the name of your State or Province?|
|What is the two-letter country code for this unit?|
Then, type “yes” to confirm the data. And done! 🤓 Our key is generated!
You will see text like in the following image:
If you go directly to the folder where you created the process, you should be able to see the myapp.keystore file.
To sign your Android application, you must make certain configurations at the project level. To do so, we will add a set of data contained in Configuration Tags. To understand it better, we will divide the explanation into two points:
1. Understanding configuration tag descriptions
|Accepts a bool value, you must add them as True to sign your app.|
|This is the name of the key storage file created in the previous step.|
|This is the alias value you assigned in the previous step with the KeyTool.|
|The password you provide when creating the keystore file.|
2. Implementation in code
Go to the ProjectName.csproj file. Then go to the end of this file, just before the end of the
</Project> tag, and paste the following code:
<PropertyGroup Condition="$(TargetFramework.Contains('-android')) and '$(Configuration)' == 'Release'"> <AndroidKeyStore>True</AndroidKeyStore> <AndroidSigningKeyStore>myapp.keystore</AndroidSigningKeyStore> <AndroidSigningKeyAlias>MyAppkey</AndroidSigningKeyAlias> <AndroidSigningKeyPass>password</AndroidSigningKeyPass> <AndroidSigningStorePass>password</AndroidSigningStorePass> </PropertyGroup>
📣 Be sure to fill in the information on the correct tags.
We have two ways to do this. First, let’s learn through the interface form, and then we will go to the terminal.
First, at the top of your project change the “Debug” mode to “Release.”
Then go to your Project ➡ Right-click ➡ Build
These steps create a release build and in your project, you should see the abb file for upload to the Google Play Store.
Let’s go back to the terminal, where we will insert a command line. But before seeing what the line is, let’s know the parameters that compose it:
|-f or --framework||Is responsible for the target framework, which is net6.0-android.|
|-c or --configuration||Is the build configuration, which is Release.|
|/p:AndroidSigningKeyPass||This is the password you provided when you created the keystore file in the tag. (In this case is “password”)|
|/p:AndroidSigningStorePass||This is the password you provided when you created the keystore file in the tag. (In this case is password)|
Implementation in Code
Once the terminal is open, execute the following command line, taking into account the information above in the parameters.
dotnet publish -f:net6.0-android -c:Release /p:AndroidSigningKeyPass=password /p:AndroidSigningStorePass=password
Finally, you can go into your Bin ➡ Release ➡ net 6.0 android folder and you’ll see the following generated files:
⚠ There are two aab files, one unsigned and one signed which has “-signed” prefix in the file name (specifically com.companyname.testingapp-Signed.aab). This is the file that you will upload to show in Google Play.
And done! 😎 Our app is ready to be uploaded to Google Play! For more information on licensing and uploading apps, you can visit this link.
Use a component library in sync with .NET MAUI’s release cadence. Try Telerik UI for .NET MAUI for free.
I hope you enjoyed reading and that this article has been very useful to you!
See you later! 🙋♀️
Leomaris Reyes is a Software Engineer from the Dominican Republic, with more than 5 years of experience. A Xamarin Certified Mobile Developer, she is also the founder of Stemelle, an entity that works with software developers, training and mentoring with a main goal of including women in Tech. Leomaris really loves learning new things! 💚💕 You can follow her: Twitter, LinkedIn , AskXammy and Medium.
Subscribe to be the first to get our expert-written articles and tutorials for developers!
All fields are required