Closed developer9969 closed 3 years ago
@PureWeen: Looks like this might be an issue others are also having after updating to more recent Material versions: https://stackoverflow.com/questions/63168050/android-resource-linking-failed-android-studio
@developer9969 Where does this generated XML come from?
@developer9969
@hartez @PureWeen
thanks for your replies I have tried to create a repo but cannot replicate in a noddy sample.
That code I guess is generated by android somehow...
I had a mixture of Android.Support libraries and AndroidX but I did not have any nuget package that uses material. and the error did not give any clue
However I have fixed the issue by running the AndroidX Migrator and noticed that it replaced all the support with AndroidX equivalent but more importantly I think the one that made the difference was as below.
Xamarin.Android.Support.Design with Xamarin.Google.Android.Material and now the solution compiles,
in fact because it removed support.Design the code below now uses uses Xamarin.Google.Android.Material e.g BottomNavigationView. instead of support library.
` public class TabbedPageNoShiftEffect : PlatformEffect
{
protected override void OnAttached()
{
if (!(Container.GetChildAt(0) is ViewGroup layout))
return;
if (!(layout.GetChildAt(1) is BottomNavigationView bottomNavigationView))
return;
// This is what we set to adjust if the shifting happens
bottomNavigationView.LabelVisibilityMode = LabelVisibilityMode.LabelVisibilityLabeled;
}
protected override void OnDetached()
{
}
}`
In conclusion obviously something has drastically changed in 5 and the error given was not helpful but your mentioning of androidX made me try the migrator which fixed the issue and highlight the problem.
It compiles now I have to check if things still work :)
thanks for replying
@mattleibow ? Any thoughts?
@PureWeen @mattleibow @hartez Hi there , apologies for being vague but I am struggling to build a repo to show our problem, I cannot post our client project , upgrading to XF5 is failing android projects where you have a mixture of AndroidSupport Library and AndroidX library.
As soon as upgraded to 5 the solution not longer builds and I get "failed linking file resources" see pic above in the thread that is just an android library that we use , to fix it I had
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.3" />
and replace with <PackageReference Include="Xamarin.Google.Android.Material">
<Version>1.2.1.1</Version>
</PackageReference>
However the main solution we get
\obj\Debug\100\lp\138\jl\res\xml\standalone_badge_offset.xml(19): error APT2259: '10dp' is incompatible with attribute horizontalOffset (attr) float [weak].
\obj\Debug\100\lp\138\jl\res\xml\standalone_badge_offset.xml(19): error APT2259: '5dp' is incompatible with attribute verticalOffset (attr) float [weak].
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets(164,3): error APT2061: failed linking file resources.
No sure where the above is coming from... some linking attribute is going wrong.
Workaround Use 4.8.0.1560 and all works without doing anything
Has something changed in regards to using Xamarin.Android.Support.Design and AndroidX? Can both live together? unfortunately till some of the nuget we use dont update we are stuck with both!!!
Does the above give enough to go on?
many thanks
Same problem when update XF 4.8 to 5.0 lastest.
After Clean Solution and Rerun. It work fine..
@haiduong741 hi there, I deleted bin/obj too but does not go away for me . we are STUCK now, just hope it gets prioritized do you have a small repo to replicate the issue . It might get fixed earlier. thanks
It only run OK one time. Error still appear again. I have tried a repo but it run ok with XF 5.0. Only my company's project error...
@PureWeen @hartez @mattleibow I have attached a small repo (see intial post) just build the solution and you should see the error. this is stopping us upgrading, Is this something for the Android Team? Hopefully you will get the time to look into this one. Many thanks
You can try on 5.0.0.1791-pre5 version, it solved this my issue but 5.0.0.1874 still got problem.
@dphamsafetrust hi interesting but that is an old version not a new one.Do you have same issue as I do?
@dphamsafetrust hi interesting but that is an old version not a new one.Do you have same issue as I do?
Exactly same :)
@dphamsafetrust problem is it does not seems to be in the list of items they are working on for 5.01 and we will never be able to upgrade until is fixed or someone suggests a workaround.
Pls answer or attach a solution for this. @hartez Thanks.
@developer9969 hi there we have exactly the same issue .Any news or workaround?
@PureWeen @hartez any suggestions?
many thanks
This happens with my project as well
Hi there we love xamarin and we would like to upgrade to the latest , we totally get it that you are very busy as there many bugs raised daily but I think the inability to upgrade to the latest code is quite important. Could someone from the Xamarin team reply to this thread?
@developer9969 sorry if I've missed some steps but what do I do with your sample to reproduce? I downloaded it and it's running fine for me. I also removed all of the support and androidx packages and it still ran fine for me.
@haiduong741 @gabsterdev1 @BYES-PA do you have repros?
If you disable aapt2 in the project properties does that fix the issue for you?
@haiduong741 @gabsterdev1 @BYES-PA @developer9969 @dphamsafetrust
If that still doesn't work can you install this tool here to create a binlog of your build and then attach that here? https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProjectSystemTools
If you disable aapt2 in the project properties does that fix the issue for you?
My Company's project:
Enable aap2:
My project has been installed lastest:
When click to error list, this file is open (path: obj\Debug\110\lp\181\jl\res\layout\mtrl_calendar_month_navigation.xml):
@PureWeen thank you for your reply. I kind of dont understand how my repro proj just works for you. As soon as you download and build do you get the error?
See below again my repo and logs.
I hope you guys can reproduce and fix it as is holding us up to use the community toolkit too.
@PureWeen see below video is 5 mins but you can skip as you see fit
- I would uninstall any support/androidx libraries you have installed and just let them transitively come from forms
@PureWeen This worked for me. I get other errors now, but I have yet to determine if they are related to this issue.
@BYES-PA hi there , did it work for you?did you have same error as me?
@developer9969 Yes, uninstalling any support/androidx library worked. Yes, I had exactly the same error. I had another unrelated error (some xml error) which was fixed by setting the dex compiler from dx to d8.
- I would uninstall any support/androidx libraries you have installed and just let them transitively come from forms
@PureWeen this worked for me. Thank you so much.
I Also have the same issue and tried everything in this thread with no luck.
Error failed linking file resources. XxxxApp.Android Error '10dp' is incompatible with attribute horizontalOffset (attr) float [weak] Error '5dp' is incompatible with attribute verticalOffset (attr) float [weak]
Running VS 16.8.4 Have set project min and target to Android 11, Api 30 - R Deleted bin/obj multiple times Have run the Migration tool.
Nothing worked with the final package references below.
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.2.1.1" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.2.0.5" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.5" />
<PackageReference Include="Xamarin.AndroidX.CardView" Version="1.0.0.5" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.2.0.1" />
<PackageReference Include="Xamarin.Plugin.FilePicker">
<Version>2.1.41</Version></PackageReference>
<PackageReference Include="Xamarin.AndroidX.Migration" Version="1.0.8" />
(I also tried removing Cardview, MediaRouter & Legacy - same error) I then rolled back to the .csproj before I migrated and was prompted to install
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.2.0" />
<PackageReference Include="Xamarin.AndroidX.Palette" Version="1.0.0.5" />
I did then built without runinig the migration tool and it builds and runs with the references below :-
<PackageReference Include="Xamarin.Forms" Version="5.0.0.1874" />
<PackageReference Include="Xamarin.AndroidX.Migration" Version="1.0.8" />
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Plugin.FilePicker" Version="2.1.41" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.2.0" />
<PackageReference Include="Xamarin.AndroidX.Palette" Version="1.0.0.5" />
Horrible but for now that has me running forms 5 on Android until this gets properly fixed
@developer9969 (and anyone else still having the issue) can you try to attach a binlog using the following tool?
https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProjectSystemTools
You can also try to run
msbuild <yourproject> /bl
This will create a file called msbuild.binlog
If you don't feel comfortable attaching that file here then just email it to me shneuvil at microsoft.com
@PureWeen you can repro with my Microsoft MVP Companion app project. Instead of just cloning (it is a large solution), just pop in and see the csproj) https://github.com/LanceMcCarthy/MvpApi/blob/dev/src/MvpApi.Forms/Android/MvpApi.Forms.Android.csproj
I get the same errors:
Severity Code Description Project File Line Suppression State
Error failed linking file resources. MvpApi.Forms.Android
Severity Code Description Project File Line Suppression State
Error '10dp' is incompatible with attribute horizontalOffset (attr) float [weak]. MvpApi.Forms.Android C:\Source\GitHub\MvpApi\src\MvpApi.Forms\Android\obj\Debug\100\lp\97\jl\res\xml\standalone_badge_offset.xml 19
Severity Code Description Project File Line Suppression State
Error '5dp' is incompatible with attribute verticalOffset (attr) float [weak]. MvpApi.Forms.Android C:\Source\GitHub\MvpApi\src\MvpApi.Forms\Android\obj\Debug\100\lp\97\jl\res\xml\standalone_badge_offset.xml 19
I'm going to be pushing more changes as I try to fix this. to save the state of the setting, here are the package references.
<ItemGroup>
<PackageReference Include="Telerik.UI.for.Xamarin">
<Version>2021.1.119.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Core">
<Version>1.3.2.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.AndroidX.Browser">
<Version>1.3.0.4</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="5.0.0.1905" />
<PackageReference Include="SkiaSharp" Version="2.80.2" />
<PackageReference Include="SkiaSharp.Views " Version="2.80.2" />
<PackageReference Include="SkiaSharp.Views.Forms " Version="2.80.2" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.6" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.2.1.1" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.2.0.6" />
<PackageReference Include="Xamarin.AndroidX.CardView" Version="1.0.0.6" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.2.0.1" />
<PackageReference Include="Xamarin.AndroidX.VectorDrawable" Version="1.1.0.6" />
<PackageReference Include="Xamarin.AndroidX.VectorDrawable.Animated" Version="1.1.0.6" />
<PackageReference Include="Xamarin.AndroidX.RecyclerView" Version="1.1.0.6" />
<PackageReference Include="Xamarin.Android.Support.v8.RenderScript" Version="28.0.0.3" />
<PackageReference Include="Xamarin.AndroidX.Migration" Version="1.0.8" />
<PackageReference Include="Xamarin.AndroidX.Palette" Version="1.0.0.6" />
</ItemGroup>
Here's a high level summary of how the project ended up in this state:
I switched to using the implicit package restoration from XF nuspec and it now builds.
to be clear, here's what I did
Success!
@LanceMcCarthy if you just remove this one
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.2.1.1" />
Does that also fix for you?
It was breaking when that package was explicitly listed.
Here's an easy comparison for you to put side-by-side
<ItemGroup>
<PackageReference Include="Telerik.UI.for.Xamarin" Version="2021.1.119.1"/>
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.3.2.1"/>
<PackageReference Include="Xamarin.AndroidX.Browser" Version="1.3.0.4"/>
<PackageReference Include="Xamarin.Forms" Version="5.0.0.1905" />
<PackageReference Include="SkiaSharp" Version="2.80.2" />
<PackageReference Include="SkiaSharp.Views " Version="2.80.2" />
<PackageReference Include="SkiaSharp.Views.Forms " Version="2.80.2" />
<PackageReference Include="Xamarin.AndroidX.Palette" Version="1.0.0.6" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.2.0.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Telerik.UI.for.Xamarin" Version="2021.1.119.1"/>
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.3.2.1"/>
<PackageReference Include="Xamarin.AndroidX.Browser" Version="1.3.0.4"/>
<PackageReference Include="Xamarin.Forms" Version="5.0.0.1905" />
<PackageReference Include="SkiaSharp" Version="2.80.2" />
<PackageReference Include="SkiaSharp.Views " Version="2.80.2" />
<PackageReference Include="SkiaSharp.Views.Forms " Version="2.80.2" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.6" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.2.1.1" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.2.0.6" />
<PackageReference Include="Xamarin.AndroidX.CardView" Version="1.0.0.6" />
<PackageReference Include="Xamarin.AndroidX.VectorDrawable" Version="1.1.0.6" />
<PackageReference Include="Xamarin.AndroidX.VectorDrawable.Animated" Version="1.1.0.6" />
<PackageReference Include="Xamarin.AndroidX.RecyclerView" Version="1.1.0.6" />
<PackageReference Include="Xamarin.Android.Support.v8.RenderScript" Version="28.0.0.3" />
<PackageReference Include="Xamarin.AndroidX.Migration" Version="1.0.8" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.2.0.1" />
<PackageReference Include="Xamarin.AndroidX.Palette" Version="1.0.0.6" />
</ItemGroup>
I removed the Xamarin.Google.Android.Material line and it now builds & runs for me as well.
Relevant nugets after: -
<PackageReference Include="Xamarin.Forms" Version="5.0.0.1874" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.2.0.5" />
<PackageReference Include="Xamarin.AndroidX.CardView" Version="1.0.0.5" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.2.0.1" />
<PackageReference Include="Xamarin.Plugin.FilePicker">
<Version>2.1.41</Version></PackageReference>
<PackageReference Include="Xamarin.AndroidX.Palette" Version="1.0.0.5" />
@PureWeen FINALLY I have managed to build the solution , this was a complicated process has we had some android library that were having a mixture of Support and AndroidX.
I Removed all the android packages as you suggested and I let Visual studio tell me what it required. and finally built!!
the errors we were getting were not helping as it gave no idea where the problem was.
However now unfortunately the Azure Pipeline using 5.0 is failing for iOS with
MTOUCH : error MT2101: Can't resolve the reference 'System.Void UIKit.UIPageControl::set_AllowsContinuousInteraction(System.Boolean)', referenced from the method 'System.Void Xamarin.Forms.Platform.iOS.IndicatorViewRenderer::OnElementChanged(Xamarin.Forms.Platform.iOS.ElementChangedEventArgs
1
Googled it but not much luck. We are using Microsoft Hosted agents!
I would hate to revert now bcse I cannot build the app in Azure Devops
You may need to update iOS on the agents: https://github.com/xamarin/Essentials/issues/1589#issuecomment-756600412
- script: |
dotnet tool update --global boots
boots --stable XamariniOS
It's good to see we've narrowed this down to a workaround but if someone who can recreate this issue could attach a binlog that would be really helpful
https://github.com/xamarin/Xamarin.Forms/issues/13303#issuecomment-762899187
I've tried the repro projects listed here and they all compile for me fine using the latest version of the google.materials library
I'll have a quick look. Not sure if I'll see anything, but there is no harm in letting my gut run on this :) Just updating to the latest stable of everything.
I've sent you a link to my failing binlog to the email you posted previously.
So... Just starting from the top and trying the builds.
I created a new project, updated everything - making sure to use all the packages listed here. Seems to build for me.
Only thing different is that I did not add Telerik as it was not installed at the time. Installing now and will try again.
However, could someone try building this test project: App1.zip This is my binlog for a rebuild of the Android project: App1.Android_Debug_AnyCPU_Build_2021-01-21T20_24_21.1644064+02_00.binlog.zip
If someone can build that project and let me know if it works. And, regardless of if this project works, could you attach the binlog for this project so I can compare and see if I can spot something. I believe I am on the latest of all the bits, but maybe someone has something that stands out.
OK... I think I found what was causing the issue, but not how yet. So my sample app works fine, but now fails when I installed the Telerik package. Not sure what is up just yet, but for those using sample apps and also the test app above, could you test that and then install Telerik just to confirm it is that package?
EDIT I see the OP was using Syncfusion... I added all of them to my project, but no failures :( App1.Android_Debug_AnyCPU_Build_2021-01-21T20_44_53.4334615+02_00.binlog.zip
I'm also using Telerik. The plot thickens!
@mattleibow I tried your App1 project above and it builds and runs fine.
I then added in
<PackageReference Include="Telerik.UI.for.Xamarin" Version="2021.1.119.1" />
and I get the
Error failed linking file resources. App1.Android
Error '5dp' is incompatible with attribute verticalOffset (attr) float [weak]. App1.Android
Error '10dp' is incompatible with attribute horizontalOffset (attr) float [weak]. App1.Android
Coincidentally, I'm the Manager of Telerik Support in the US and can help out in digging deeper.
cc @didiyordanova are you aware of any known issues here?
@mattleibow I'm downloading your App1 test and sending it to Didi and the dev team. @Gmotagi If you would like to track our internal progress, open a BR here https://feedback.telerik.com/xamarin (click "Report a bug")
It still not working for me. No Solution really clean can fixing them.
Update: The issue was escalated and the Telerik development team is looking at this in depth today.
@haiduong741 The workaround is to let the Xamarin.Forms 5.x NuGet package restore its own dependencies (instead of you explicitly listing it).
What I mean by that is you should open your Android project's csproj file and remove the highlighted items in this screenshot:
After they have been removed, do a Clean and Rebuild.
Hi Excited to upgrade to XF 5 stable but as soon as I compile my solution my android project fails with 2 errors
Error 1 (probably linked to error 2) Severity Code Description Project File Line Suppression State Error failed linking file resources.
Error 2 verity Code Description Project File Line Suppression State Error 'textEnd' is incompatible with attribute iconGravity (attr) flags [start=1, textStart=2] [weak].
MyCompany.Mobile.droid D:\Work\MyCompany.Mobile.droid\obj\Debug\100\lp\136\jl\res\layout\mtrl_calendar_month_navigation.xml 33
the problem is that this code is autogenerated so there is nothing I can do
I also tried to add a nuget Xamarin.Google.Android.Material to see if it solves the problem but doesnt.
Reverted to 4.8.0.1560 and all good again, Hopefully someone can look at it or advise a workaround.
Thanks!
` <?xml version="1.0" encoding="utf-8"?>
` Reproduction