How To Set Up an Android Dev Environment
This guide shows you how to set up your development environment for work on a mobile Android application.
Follow these steps to install the tools you will need, using the CLI:
- Check that you have installed a compatible version of the .NET SDK. The lowest version that works with Avalonia UI is 6.0.2.00.
You can see the versions of the .NET SDK here.
- You may need to uninstall an old version of the Android Workload. To do this, type the following command:
dotnet workload uninstall android
- Install the Android Workload. To do this, type the following command:
dotnet workload install android
You may need to run the above commands with sudo.
Install the Android SDK
There are several ways to install the Android SDK. Choose the one that matches your development environment.
If you have Visual Studio or Visual Studio for Mac then follow the guide found here.
If you use JetBrains Rider then follow the guide here.
Alternatively you can install the Android command line tools from here.
This toolset has a command line based SDK manager that can be used to install the SDK. On successfully installing the Android SDK, add the path to the sdk to your PATH environment variable, directly in bash or in your profile's .bashrc file on Linux.
export ANDROID_HOME=/path/to/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
You can also directly specify the Android SDK location in the dotnet
commands when you build, run or deploy the dotnet Android project, by setting the AndroidSdkDirectory
variable in the command:
dotnet build ... /p:AndroidSdkDirectory=/path/to/sdk
Ensure you've installed the JDK 11 or above using your platform's package manager. This is already done if set up using Visual Studio or JetBrains Rider as stated above.
There is also a tool in development called MAUI Check that can install all the required SDKs and tools for you automatically:
dotnet tool install -g Redth.Net.Maui.Check
maui-check
With the above Android development environment setup, you will be able to build Android applications, and run them in a simulator on your platform.