0

When building a hybrid Xamarin Android app, we have a bizarre, intermittent issue.

The app is quite large and split into several components.

  • App1
    • App1.Android
    • App1.iOS
  • App2
    • App2.Android
    • App2.iOS
  • Shared.Core
  • Shared.Android
  • Shared.iOS

App1.Android and App2.Android share Shared.Core and Shared.Android, App1.iOS and App2.iOS shared Shared.Core and Shared.iOS. It's Shared.Android (an Xamarin Android library) which is vexing me.

When attempting to compile, sometimes the build fails because it says that Resources.Drawable doesn't contain a reference to two specific items. These are seek.xml and seek_style.xml.

However IntelliSense sees the expected value and if I look into Resource.designer.cs the values are there and when F12ing to the source the two entities are listed.

The two files are in the Resource/drawable folder and as mentioned before can be F12ed to during normal IntelliSense operations.

I've tried several guides to resolve this issue, including the one here: https://stackoverflow.com/a/36759115 but they only seem to provide temporary relief.

Does anyone have any suggestions? I'm tearing my hair out here.

Some screenshots:

  1. File with reference (and working IntelliSense): Base File
  2. Content of Resources.Drawable: Resources.Drawable
  3. Compile time errors: Compile time errors
  4. Files in Drawable folder (with properties): seek.xml properties seek_style.xml properties
Kristian Williams
  • 2,275
  • 22
  • 25
  • Hi, "sometimes the build fails because it says that Resources" . Do you mean this build successfully sometimes? – Junior Jiang Oct 12 '20 at 08:19
  • Yes, it is occasionally possible to rebuild the solution using the steps in the answer I linked, but other times that also doesn't help. – Kristian Williams Oct 12 '20 at 08:31
  • Okey, It seems that the data is not synchronized. The *seek.xml and seek_style.xml* belong to which project, and do you always modify them before compling? – Junior Jiang Oct 13 '20 at 03:18
  • They belong to the `XXX.Shared.UI.Droid` project, the same as the `Resources.cs` file and the `SeekBarRenderer.cs` file which is referencing them. I've not modified them since the project was handed over to us end of last year. – Kristian Williams Oct 13 '20 at 06:44
  • It seems to be a old shared project, maybe there are some conflicts with the current version of Xamarin Froms and Visual Studio. I will continue to reasearch which reason should be. – Junior Jiang Oct 13 '20 at 08:02
  • I can confirm it's an "old style" MSBuild format (``) project. I've tried a few times to migrate to the newer SDK style but the support for Xamarin is sketchy at best. – Kristian Williams Oct 13 '20 at 08:19
  • Maybe you could have a check with [Override ToolsVersion settings](https://learn.microsoft.com/en-us/visualstudio/msbuild/overriding-toolsversion-settings?view=vs-2019), there are some ways to change the configurations. – Junior Jiang Oct 13 '20 at 09:20
  • Could you elaborate more on what I'm supposed to do with this? Currently it builds using MSBuild v16, are you saying I should try to force it to use v15 instead? – Kristian Williams Oct 13 '20 at 12:42
  • Sorry, I mistaked you used the old version of MSBuild. If no, there will be no need to modify them. – Junior Jiang Oct 14 '20 at 02:49
  • I am running on MSBuild v16 on an up to date version of Visual Studio Professional 2019. – Kristian Williams Oct 14 '20 at 06:42
  • Hi, maybe you could have a try with cleaning the content of file [Resource.designer.cs](https://i.stack.imgur.com/9wZ8Y.png) , then rebuild the `XXX.Shared.UI.Droid` project. – Junior Jiang Oct 15 '20 at 08:54
  • When _emptying_ the Resources.designer.cs file, it is not regenerated on build, but is on rebuild. After rebuild `seek` and `seek_style` are both present. After _deleting_ the Resourse.desginer.cs file, it is regenerated with the `seek` and `seek_style` properties included. Still getting the two compile-time CS0117s though. – Kristian Williams Oct 15 '20 at 14:43
  • Okey, all the projects whether use the latest version of Visual Studio and Xamarin Froms? – Junior Jiang Oct 16 '20 at 02:01
  • Yes, I am using the latest VS Professional 2019 version and Xamarin Forms is up to date. I noticed a change in behavior after deleting the Resources.designer.cs file, rebuilding and then "including" the newly generated version. It did build but I'm not sure if it's repeatable. Why aren't line breaks allowed in comments... – Kristian Williams Oct 16 '20 at 06:55
  • After rebuilding again the error reappears :( – Kristian Williams Oct 16 '20 at 06:56
  • Another interesting quirk: if Resources.designer.cs is not included in the project, when regenerated then the references to seek and seek_style are not present! – Kristian Williams Oct 16 '20 at 06:59
  • Hi, since the project structure is complex, and it seems no other people know the problem how to solve, then you could consider open a support ticket at http://support.microsoft.com/supportforbusiness/productselection?sapId=211dd84f-3474-c3c5-79bf-66db630c92a6 to get a more comprehensive support. – Junior Jiang Oct 16 '20 at 08:57
  • what are the contents of your xml files? does it contain key value pairs? – Nitin Sawant Oct 21 '20 at 06:31
  • They are Android drawable/SVG style objects. I will reference one tomorrow for you. – Kristian Williams Oct 21 '20 at 20:17

1 Answers1

0

Resources/drawable folder − It stores all the images that you are going to use in your application.

Resources/values folder − It contains XML files to declare key-value pairs for strings (and other types) throughout an application. This is how localization for multiple languages is normally set up on Android.

You need to move the seek.xml and seek_style.xml files in Resources/Values folder and in properties window of xml files set:
enter image description here

Nitin Sawant
  • 7,278
  • 9
  • 52
  • 98
  • I already tried this and it didn't help, normally the files located in Resources/drawable work as expected only during certain rebuild actions do they fail. – Kristian Williams Oct 21 '20 at 20:16