Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build variants in Xamarin for Android

We currently have an Android application that we would like to translate to Xamarin for Android.

Our app uses build variants to create different product flavors.

However I cannot find any documentation explaining whether this is possible in Xamarin or what would be the workaround.

Does anybody have experience with this issue?

Thanks in advance.

like image 376
Schiavini Avatar asked Apr 10 '14 09:04

Schiavini


People also ask

How to use build variant in Android?

You can change the build variant to whichever one you want to build and run—just go to Build > Select Build Variant and select one from the drop-down menu. To start customizing each build variant with its own features and resources, however, you'll need to know how to create and manage source sets.

Where is build variants in Android Studio?

By default, Android Studio builds the debug version of your app, which is intended for use only during development, when you click Run. To change the build variant Android Studio uses, select Build > Select Build Variant in the menu bar.

How to change build variant?

NOTE: By default, the Android Studio will generate "debug" and "release" Build Types for your project. So, to change a Build Type, all you need to do is just select your Build Type from the Build Variant and after the project sync, you are good to go.

Is xamarin good for Android development?

Ultimately, appreneurs should use Xamarin for building mobile apps, as the platform offers an excellent means to build mobile apps without utilizing OS-specific languages like Swift or Java. The advantage of this is more efficient and comprehensive development as codebases can be shared cross-platform.


1 Answers

Both of those concerns (product flavours and build variants) aren't really an "Android" thing, they are a software configuration issue that Gradle supports.

Although Xamarin.Android doesn't support Gradle, it is possible to create build variants as described in that link. Xamarin.Android allows you to choose the ABI's that you're targeting. With a bit of scripting you can create one APK per ABI (which you can then upload to Google Play).

Likewise, with the appropriate scripting, you could also support product flavours in a couple of different ways:

  • Using compile time directives, i.e. #if statements
  • Architect your app so that certain features are in certain assemblies that are omitted at compile time or a different for each flavour.
like image 67
Tom Opgenorth Avatar answered Sep 20 '22 18:09

Tom Opgenorth