0xFireball / xamarin-android-linux

Detailed instructions on setting up Xamarin.Android on Linux!

Home Page:https://blog.iridiumion.xyz/guides/2018/02/03/xamarin-android-linux/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting up Xamarin.Android on Linux

A guide to getting Xamarin.Android ready to use on your distro of choice!

This guide has been tested successfully:

  • Arch Linux as of Feb 3, 2018
  • Ubuntu 16.04 (mono-5.8) as of Feb 23, 2018

Note that this is officially unsupported, but it can be used as a loose guide to help in setting this up on your system.

works badge

Why?

Xamarin has stated that there are no plans to officially support Linux. However, since Xamarin was open sourced, the developers have made it possible to manually install Xamarin.Android, and with some tweaking we can get full debugging support in Rider!

Let's start

Prerequisites

  • Latest mono packages for your platform

Obtain Xamarin.Android binaries

Prebuilt Releases (Recommended)

The latest successful artifacts from automated builds for Linux are available here: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-linux/lastSuccessfulBuild/Azure/

Download the xamarin.android-oss_*.orig.tar.bz2 package to your system and extract it.

From source

See their instructions on building from source.

Environment setup

Install the Android SDK and NDK, then set environment variables:

(You may have to adjust the paths; these are the default for Android Studio)

export ANDROID_SDK_PATH=$HOME/Android/Sdk
export ANDROID_NDK_PATH=$HOME/Android/Sdk/ndk-bundle

Test build

Build a test project (there's one in the source repository) for Xamarin.Android.

/path/to/xamarin.android-oss*/bin/Debug/bin/xabuild /path/to/samples/HelloWorld/HelloWorld.csproj

The build should complete successfully. If you have problems, try adding /verbosity:d to get detailed output from the build process. You may have a minor error about libzip.so.4 not being found, just create a symlink to your libzip:

sudo ln -s /usr/lib/libzip.so /usr/lib/libzip.so.4

Next, try building a signed package:

/path/to/xamarin.android-oss*/bin/Debug/bin/xabuild /path/to/samples/HelloWorld/HelloWorld.csproj /t:SignAndroidPackage

This will invoke keytool and generate a keystore and use it to sign an .apk file, which will go to your output directory with a name like YourTestProject-Signed.apk.

Bonus: IDE (especially JetBrains Rider) support

This will enable building Xamarin.Android projects directly from msbuild.

Please refer to rider-setup.md.