Mauro
Mauro

Reputation: 127

Error : Attribute already defined with incompatible format in "attrs.xml" in Xamarin.Android

I'm using Xamarin for developing my application. I've no problem with other platform such as UWP and iOs.

But when I try to build Android app I receive these errors:

Errors shown in Visual Studio 2017

All these errors refers to "attrs.xml" file shown belowe :

    <?xml version="1.0" encoding="UTF-8"?>
<resources>
   <declare-styleable name="DrawableStates">
      <attr name="state_indeterminate" format="boolean" />
   </declare-styleable>
   <declare-styleable name="SfCheckBox">
      <attr name="isthreestate" format="boolean" />
      <attr name="cornerradius" format="float" />
      <attr name="checked" format="enum">
         <enum name="unchecked" value="0" />
         <enum name="indeterminate" value="1" />
         <enum name="checked" value="2" />
      </attr>
   </declare-styleable>
   <declare-styleable name="SfSegmentedControl">
      <!--        The selected index of SfSegmentCondrol-->
      <attr name="segmentSelectedIndex" format="integer" />
      <!--        The backcolor of SfSegmentCondrol-->
      <attr name="segmentBackColor" format="color" />
      <!--        The border color of SfSegmentCondrol-->
      <attr name="segmentBorderColor" format="color" />
      <!--        The border thickness of SfSegmentCondrol-->
      <attr name="segmentBorderThickness" format="string" />
      <!--        The color of SfSegmentCondrol-->
      <attr name="segmentColor" format="color" />
      <!--        The segment padding of SfSegmentCondrol-->
      <attr name="segmentedPadding" format="string" />
      <!--        The segment height of SfSegmentCondrol-->
      <attr name="segmentedHeight" format="string" />
      <!--        The segment width of SfSegmentCondrol-->
      <attr name="segmentedWidth" format="string" />
      <!--        The stroke thickness of SfSegmentCondrol-->
      <attr name="segmentStrokeThickness" format="string" />
      <!--        The corner radius of SfSegmentCondrol-->
      <attr name="segmentCornerRadius" format="string" />
      <!--        The position of SfSegmentCondrol-->
      <attr name="segmentPosition" format="enum">
         <enum name="top" value="0" />
         <enum name="bottom" value="1" />
         <enum name="fill" value="2" />
         <enum name="border" value="3" />
      </attr>
      <!--        The displaymode of SfSegmentCondrol-->
      <attr name="segmentDisplayMode" format="enum">
         <enum name="image" value="0" />
         <enum name="text" value="1" />
         <enum name="imagewithtext" value="2" />
      </attr>
   </declare-styleable>
</resources>

Is there any problem for my "attrs.xml" file? I already tried to clean and rebuild solutions. Remove and adding again every package but errors persists.

Thanks for your help.

Upvotes: 1

Views: 1048

Answers (1)

Leon Lu
Leon Lu

Reputation: 9234

Did you used the SfSegmentedControl from the Syncfusion like this link? https://help.syncfusion.com/xamarin-android/sfsegmentedcontrol/getting-started

Based on your error message, there are two issues.

Issue1 is related to segmentPosition segmentDisplayMode. I cannot find these attributes in SfSegmentedControl, you can refer to the following screenshot.If you want to define attributes in attrs.xml, SfSegmentedControl must have these attributes. enter image description here Solution: you could custom SfSegmentedControl to add these attributes.

Issue2 is related to SfCheckBox, the format of checked attribute is bool not enum like this screenshot.

enter image description here Solutions: change the format of checked

Upvotes: 1

Related Questions