How to develop Xamarin.Android applications on Linux with Rider

Please note that Xamarin.Android on Linux is officially unsupported. However, it is possible to manually install Xamarin.Android and configure Rider so that it can build and run Xamarin.Android apps on Linux. This guide has been tested on Ubuntu 16.04.

Install the latest stable Mono

See http://www.mono-project.com/download/

sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/ubuntu xenial main" | sudo tee /etc/apt/sources.list.d/mono-official.list
sudo apt-get update
sudo apt-get install mono-devel

Install JDK

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer (or sudo apt-get install oracle-java9-installer)
sudo apt-get install default-jdk

Install Android Studio

Download Android Studio https://developer.android.com/studio/index.html
Install Android Studio https://developer.android.com/studio/install.html
Download appropriate Android SDK and NDK

Install Xamarin.Android

Download any stable build:

Choose any oss-xamarin.android_vVERSION_Linux-x86_64_HEAD*.tar.bz2 artifact from https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-linux/

Extract it:

tar xjf ./oss-xamarin.android_v{VERSION}_Linux-x86_64_HEAD{*}.tar.bz2

Goto the unpacked dir:

cd ./oss-xamarin.android_v{VERSION}_Linux-x86_64_HEAD{*}

Make dirs:

sudo mkdir "/usr/lib/xamarin.android"
sudo mkdir "/usr/lib/mono/xbuild/Xamarin/"

Copy dir form extracted files:

sudo cp -a "bin/Debug/lib/xamarin.android/." "/usr/lib/xamarin.android/"

Delete dirs for next steps:

rm -rf "/usr/lib/mono/xbuild/Xamarin/Android"
rm -rf "/usr/lib/mono/xbuild-frameworks/MonoAndroid"

Make Symlinks:

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"

Add the next lines to your csproj file:

<PropertyGroup Condition=" '$(OS)' == 'Unix' ">
    <MonoAndroidToolsDirectory>/usr/lib/mono/mandroid</MonoAndroidToolsDirectory>
    <MonoAndroidBinDirectory>/usr/lib/mono/xamarin-android/bin</MonoAndroidBinDirectory>
    <AndroidSdkDirectory>$(ANDROID_SDK_PATH)</AndroidSdkDirectory>
    <AndroidNdkDirectory>$(ANDROID_NDK_PATH)</AndroidNdkDirectory>
</PropertyGroup>

Make sure that ANDROID_SDK_PATH and ANDROID_NDK_PATH environment variables are set.

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".

You should now be able to build and run Xamarin.Android applications on Linux with Rider.

 

1 comment


I followed this, created a new Xamarin.Android project but am getting this error at build time. I have the Android_SDK_Path set correctly. An y guidance? 

 

Also the SDK is set here. I appreciate the help :) 

Edited by Michael
0

Please sign in to leave a comment.

Have more questions?

Submit a request