After updating Xamarin.Forms from 3.6.0.264807 to 3.6.0.293080 it adds a bunch of additional Android support libraries and my project is no longer able to build. I get this build output after the update:
2>------ Build started: Project: MyApp.Droid, Configuration: Debug Any CPU ------
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1703,2): error APT0000: Failed to generate resource table for split '' "Failed to generate resource table for split ''".
2>F:\Repos\MyApp\MyApp\MyApp\MyApp.Droid\obj\Debug\90\lp\80\jl\res\values\values.xml(6): error APT0000: Attribute "statusBarBackground" already defined with incompatible format.
2>F:\Repos\MyApp\MyApp\MyApp\MyApp.Droid\obj\Debug\90\lp\86\jl\res\values\values.xml(2): error APT0000: Original attribute defined here.
2>F:\Repos\MyApp\MyApp\MyApp\MyApp.Droid\obj\Debug\90\lp\80\jl\res\values\values.xml(10): error APT0000: Attribute "layout_anchorGravity" already defined with incompatible format.
2>F:\Repos\MyApp\MyApp\MyApp\MyApp.Droid\obj\Debug\90\lp\86\jl\res\values\values.xml(2): error APT0000: Original attribute defined here.
2>F:\Repos\MyApp\MyApp\MyApp\MyApp.Droid\obj\Debug\90\lp\80\jl\res\values\values.xml(17): error APT0000: Attribute "layout_insetEdge" already defined with incompatible format.
2>F:\Repos\MyApp\MyApp\MyApp\MyApp.Droid\obj\Debug\90\lp\86\jl\res\values\values.xml(2): error APT0000: Original attribute defined here.
2>F:\Repos\MyApp\MyApp\MyApp\MyApp.Droid\obj\Debug\90\lp\80\jl\res\values\values.xml(17): error APT0000: Attribute "layout_dodgeInsetEdges" already defined with incompatible format.
2>F:\Repos\MyApp\MyApp\MyApp\MyApp.Droid\obj\Debug\90\lp\86\jl\res\values\values.xml(2): error APT0000: Original attribute defined here.
2>F:\Repos\MyApp\MyApp\MyApp\MyApp.Droid\obj\Debug\90\lp\80\jl\res\values\values.xml(17): error APT0000: Color types not allowed (at 'statusBarBackground' with value '#000000').
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
So far, if I take it correctly, there is an issue within the Xamarin.Android.Common.targets file which is not part of my project? Because every other message is related to a obj folder output. But if this is the case, what can I do to fix the issue? I would like to use the newer version because I have the hope that a few bugs in Xamarin.Forms are resolved (like the Navigating Cancel ignore issue on the WebView).
The dependency list between the two versions should be the same
https://www.nuget.org/packages/Xamarin.Forms/3.6.0.264807
https://www.nuget.org/packages/Xamarin.Forms/3.6.0.293080
A lot of times when you update it'll still just mention all the support libraries but it won't actually update and change them.
Try
if none of that works can you include a project to recreate?
@PureWeen This is what NuGet wants to change in my Droid project for the update (and yes, he adds all those libraries): https://i.imgur.com/LVApXZo.png
I already tried to clear the obj/bin folder and also done a restart of VS with a rebuild. Sadly it results in the same error. I'm not sure what causes the issue so I'm not sure how I can create a sample repo for the issue.
What I noticed already before I update the Xamarin.Forms package are lines like this within the Resource.designer.cs: https://i.imgur.com/Fq5yGzA.png Is this even allowed (dots within the property name)? Or is the file maybe generated in a bad state? And if so, how can I force the VS to create a proper Resource.designer.cs?
@Sebastian1989101
If you concerned about the contents of Resource.designer.cs not being in sync with the rest of the project, you should be able to
If you are concerned about possibly losing something, you could always back it up as well.
Hope that helps 🙂
@Sebastian1989101 can you paste your csproj file here before you apply the update
@PureWeen Sorry for the late answer, this is the current *.csproj file: https://pastebin.com/f6TxWwGk
@AntRemo The file is always generated the same way (I guess this is how it should work anyway). But still, the "." within the const variable name looks kinda odd to me.
@Sebastian1989101 Gotcha...well that was my guess 🙂
Good luck, will be monitoring this thread as I have not upgraded yet.
@Sebastian1989101 my guess is that it's some quirk with packages.config. A lot of times it'll add multiple versions of XF or do odd things with support.
You should be able to right click packages.config and convert to PackageReference. I realize that's not the best answer but it'll most likely fix your issue. There weren't any dependencies that changed between the stated XF versions so it sounds like there's some duplication or incorrect references that linger when updating.
@PureWeen After changing to PackageReferences the Droid project required MutliDex enabled to build. Is this normal? I thought that the PackageReference is the same as the packages.config before? So why does it exceed the function limit without changing any package version?
At least I'm able to update the Xamarin.Forms package without any problem this way...
@Sebastian1989101 that's hard to answer specifically. Support 28 unfortunately does require multidex or proguard currently . We added some targets so Proguard should work out of the box now. There is also work being done on the android side to improve the multidex story.
My guess is that when you had packages.config setup your project was for some reason not referencing all the associated support libraries but it was enough of them to be functional. The new XF package must have referenced something in a library you weren't referencing so when you switched to PackRef then it more correctly pulled in all the support library dependencies.
But that's just a random guess :-) That or you were using support 27
I fixed the problem like this.
Thanks @Sebastian1989101 ;-) Migrating Package.json File to PackageReference to resolved problem.
Most helpful comment
Thanks @Sebastian1989101 ;-) Migrating Package.json File to PackageReference to resolved problem.