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.
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.
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.
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.
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.
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:
#if
statementsIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With