SOLVED

How to build MAUI to apk?

Copper Contributor

i try publish,it can not work

6 Replies
best response confirmed by SampsonYe (Copper Contributor)
Solution

@SampsonYe 

 

Using the dotnet cli you can build an apk using the following command:

 

dotnet build -f net6.0-android

 

The apk file will be built, and you can find it at <app-root-dir>/bin/release/net6.0-android/com.companyname.appname-Signed.apk

@StrathdeeK 

Wowo  nice, it work!!

just use dotnet cli can finish it

 

but why VS 2022 Preview Can't publish suitable apk?

SampsonYe_0-1637858578222.png

 

@SampsonYe 

In the MAUI proj settings, there is a combobox/dropdownlist where you set your preferences
See Android package section

NicolasKrier_0-1669301784911.png

 

But when bundle (aab) is made, it generates the apk too at the same time.
Check your bin\Release\net7.0-android folder

Take a look at the docs as well: https://learn.microsoft.com/en-us/dotnet/maui/android/deployment/overview?view=net-maui-7.0

THe default is an app bundle when publishing as this is the standard format, but you can change it in your csproj settings.
Open a command prompt and navigate to the directory where your MAUI project is located.
Run the following command:
dotnet publish -c Release -r Android -p:PackageFormat=Apk
This will create an APK file in the bin\Release\Android\ directory of your project.
Here is a more detailed explanation of the steps:
The dotnet publish command is used to build a .NET MAUI app.
The -c Release option specifies that the app should be built in release mode.
The -r Android option specifies that the app should be built for Android.
The -p:PackageFormat=<a href="https://apkthrills.com/zombie-tsunami-mod-apk/">Apk</a> option specifies that the app should be packaged as an APK file.
I hope this helps!

@SampsonYe Right click on the project and hit publish. Make sure you have the desired framework selected and it will create the archive.

 

Not sure why MS felt the need to change this but still leave the View Archives option.

1 best response

Accepted Solutions
best response confirmed by SampsonYe (Copper Contributor)
Solution

@SampsonYe 

 

Using the dotnet cli you can build an apk using the following command:

 

dotnet build -f net6.0-android

 

The apk file will be built, and you can find it at <app-root-dir>/bin/release/net6.0-android/com.companyname.appname-Signed.apk

View solution in original post