Thanks to the awesome guys at JetBrains and their Project Rider IDE, it’s now possible (unofficially) to develop Xamarin.Android apps on Linux.
This is a basic project created with Project Rider and running on the emulator:
Once I had a basic application up and running, I tried an application I’ve had in the store for a while (Temperament). It worked perfectly:
Setup Android Studio
Before installing Android Studio, starting with Ubuntu 18.04 you need to install qemu-kvm. Enter these commands:
sudo apt install qemu-kvm
sudo adduser $USER kvm
Next install Android Studio by downloading from here, extracting the archive, then running bin/studio.sh
Once Android Studio is up and running, test you can create a simple Android project and deploy to a virtual device (I created a Nexus 5×28 x86_64 device).
Now install SDK 28 and the NDK bundle via Android Studio.
Install Mono and .Net Core
Update your .bashrc (found in your home folder), it should look something like this:
Note: I had installed Android SDK to the default folder: $HOME/Android/Sdk
The next thing we need to do is create a sym link to the Android Emulator:
ln -s ../emulator/emulator emulator-x86
Install Oracle JDK
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
Download a stable build from here.
I used: xamarin.android-oss_v184.108.40.206_Linux-x86_64_master_878ba261-Debug.tar.bz2
tar xjf ./xamarin.android-oss_v220.127.116.11_Linux-x86_64_master_878ba261-Debug.tar.bz2
Go to the unpacked dir:
sudo mkdir "/usr/lib/xamarin.android" sudo mkdir "/usr/lib/mono/xbuild/Xamarin/"
Copy dir from extracted files:
sudo cp -a "bin/Debug/lib/xamarin.android/." "/usr/lib/xamarin.android/"
Delete dirs for next step:
rm -rf "/usr/lib/mono/xbuild/Xamarin/Android" rm -rf "/usr/lib/mono/xbuild-frameworks/MonoAndroid"
sudo ln -s "/usr/lib/xamarin.android/xbuild/Xamarin/Android/" "/usr/lib/mono/xbuild/Xamarin/Android" sudo ln -s "/usr/lib/xamarin.android/xbuild-frameworks/MonoAndroid/" "/usr/lib/mono/xbuild-frameworks/MonoAndroid"
Configure SDK and NDK paths in Rider settings
Go to “File | Settings | Build, Execution, Deployment | Xamarin” and set “Android SDK location” and “Android NDK location”.
Update your Project File
You can now create a new Xamarin.Android project.
Whether you are creating a new project, or using an existing one, you need to update your project file. Open the .csproj file in your favourite editor, find this section:
<PropertyGroup Condition=” ‘$(Configuration)|$(Platform)’ == ‘Debug|AnyCPU’ “>
And add this setting:
If you are using an existing project, you need to update the import directive at the end of the project file from this:
<Import Project=”$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets” />
You should now be able to build and deploy your project to a virtual device on Linux.
I’d like to say a big thank you to the JetBrains team for this blog, and to Andreas Go for his help with getting the project file right. Project Rider is shaping up to be an awesome IDE.