Telerik blogs
MobileT_1200x303

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!

Terms To Remember

First of all, keep in mind the following terms. In the process of distribution of an Android application, two type of files are generated:

  • Android Package (apk): It’s used to install your application on your Android device.
  • Android App Bundle (aab): It’s used to publish your application in the Android Store.

Step 1: Creating the Keystore File

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:

  1. Click on View ➡ Terminal.

Terminal

  1. Run the following line of command. (⚠ Make sure your terminal is located in the path of your project):
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.

Parameter nameDescription
keystoreThis 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.
keysizeNumber of bytes that are used for encryption.
validityNumber of days until the expiration of your certificate.

Once executed, it will ask you for a password to continue:

keystore

Then you must fill out a set of questions:

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?

Keystore question example

Then, type “yes” to confirm the data. And done! 🤓 Our key is generated!

You will see text like in the following image:

keystore generate

If you go directly to the folder where you created the process, you should be able to see the myapp.keystore file.

Step 2: Adding a Reference to the 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

NameDescription
<AndroidKeyStore>Accepts a bool value, you must add them as True to sign your app.
<AndroidSigningKeyStore>This is the name of the key storage file created in the previous step.
<AndroidSigningKeyAlias>This is the alias value you assigned in the previous step with the KeyTool.
<AndroidSigningKeyPass> and <AndroidSigningStorePass>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.

Step 3: Creating Our Android App Bundle File (aab)

We have two ways to do this. First, let’s learn through the interface form, and then we will go to the terminal.

From the Interface

First, at the top of your project change the “Debug” mode to “Release.”

switch debug to release

Then go to your Project ➡ Right-click ➡ Build

Build testingApp

These steps create a release build and in your project, you should see the abb file for upload to the Google Play Store.

result

From the Terminal

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:

ParameterDescription
-f or --frameworkIs responsible for the target framework, which is net6.0-android.
-c or --configurationIs the build configuration, which is Release.
/p:AndroidSigningKeyPassThis is the password you provided when you created the keystore file in the tag. (In this case is “password”)
/p:AndroidSigningStorePassThis 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:

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.

Conclusion

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! 🙋‍♀️

Reference

https://docs.microsoft.com/en-us/dotnet/maui/android/deployment/overview


LeomarisReyes
About the Author

Leomaris Reyes

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.

Related Posts

Comments

Comments are disabled in preview mode.