Building Android apps on Linux #8733
AzuxirenLeadGuy
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone. I am a Linux user and for a long time, I have been trying to build a mobile application on Linux with C#. In the official documentation for Uno, it is listed that it is not supported to build for android in Linux, but I have finally been successful to do so. Here are the steps I followed in my Linux machine (Ubuntu 21.10 x86_64).
android-sdk
with apt and add the environment variables to the pathNext, ensure the following environment variables are initialized in the
.bashrc
fileFor me, the files were installed in the path
usr/lib/android-sdk
. So it goes without saying that if the files are installed elsewhere in your machine, you'll need to edit the path accordingly.Go to https://developer.android.com/studio/command-line and download the command-line tool and extract it anywhere in your machine. Then run the following:
At this point, you should have all the tools required to build the apk file. You can confirm that all tools are installed correctly using
This will list the packages that are a) already installed, b) Yet to be installed, c) Yet to be updated
Ensure that these packages are installed:
targetframeworks
within theMobile.csproj
Now, create a new project for Uno. I am using the
unoapp-winui-net6
templateNow edit the
MyNewApp.Mobile.csproj
to have a single target framework, that isnet6.0-android
. In other words, change the line fromto
Next, install the workload for android as shown:
I also went ahead and ensured that the
MinSdkVersion
is set to 29, because of the environment I am running it in. If you need to do the same, you can edit it in the fileMyNewApp.Mobile/Android/AndroidManifest.xml
Now finally, you can build by going to the
MyNewApp.Mobile
folder and usingThe initial build takes a while and finally, the signed apk files are generated successfully.
Now for testing the apps, I am using waydroid to run the apps. I am able to install and run the sample template program successfully.
I hope this helps out people like me who wanted to build Android apps on Linux. Now I am no expert in android app development, so let me know if I am doing anything incorrectly.
Beta Was this translation helpful? Give feedback.
All reactions