Hello Xamarin Community,
i am facing a problem while sharing resources across Android apps.
In Short: I would like to centralize most parts of the android UI across similar apps, except some in this case customer specific resources, like strings, colors, images, fonts etc...
In my scenario there is a Backend modeled as a PCL which is shared over two platform specific libraries, one is my so called AndroidLib. There are numerous customers, who will get their specifically branded app for each platform in this case i am in charge for the customer specific Android apps. Each Customer requires some customization, but not every customer wants the same amount of customization, there are sensible Defaults for strings, colors etc. which should be shared across multiple android projects for all customers. Sharing resouce-independent code causes no problem, but resource-dependent code does. The following structure outlines the given scenario:
AndroidLib [AndroidLibrary] : Provides Code and Defaults for Android Apps -> Backend
C1Android [AndroidApp] : App for Customer 1 -> AndroidLib
C2Android [AndroidApp] : App for Customer 2 -> AndroidLib
Xamarin's Android Library Project type allows to merge resources scattered over several Android Library Projects including the Android App Projects, this is valuable solution to add new resources. However this method seems to disallow overwriting of resources, e.g. when a layout in the library project which depends on dummy resources being defined later in a customer specific project.
A first attempt of mine was to use the Android Library Project's resource merge mechanism to overwrite a previously defined resource, but without success. It seems that the first time a resource is bound to a value, this is going to be its final value, independent of whether another value is set to the resource afterwards. To clarify the approach take a look at the following:
This ends up with an application showing the string "dummy value" defined via the main.axml. Expected output would have been "123" to me, as it is defined within the Customer 1's Android Project. The same holds for images as well. Maybe there is some flag which can be set to activate such overwrite behavior within the msbuild tasks.
Does anybody have some thoughts or some valid workarounds about this ? Maybe i am undermining the usual way of solving this kind of resource sharing/overwriting task. I am new to xamarin just as a side not, and i am faced with an already existing code base so my possibilities are a little bit constrained, but i am always open minded
Thanks in advance