2

我不怎麼解決這個問題。它在許多活動中表現出同樣的錯誤。 如何解決它?生成簽名的APK - 錯誤:(57)解析XML時出錯:cardview中的重複屬性?

在此先感謝。

XML:

<LinearLayout android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:descendantFocusability="blocksDescendants" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    xmlns:app="http://schemas.android.com/apk/res-auto"> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     card_view:cardBackgroundColor="@color/myTextPrimaryColor" 
     card_view:cardCornerRadius="10dp" 
     app:cardUseCompatPadding="true" 
     card_view:cardElevation="1dp" 
     card_view:cardUseCompatPadding="true" 
     android:id="@+id/cv" 
     > 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal"> 

     <ImageView 
      android:layout_width="130dp" 
      android:layout_height="120dp" 
      android:layout_weight="0" 
      android:id="@+id/pimage" 
      android:src="@drawable/sliper" 
      android:focusable = "false" 
      android:focusableInTouchMode = "false" 
      android:layout_marginTop="15dp" 
      android:layout_marginRight="10dp" /> 

     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 

      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="@string/itemname" 
       android:textColor="@color/myNavigationColor" 
       android:id="@+id/itemname" 
       android:layout_marginTop="20dp" 
       android:textStyle="bold" 
       android:paddingRight="10dp" /> 
      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="balck, 16gb" 
       android:textColor="@color/myNavigationColor" 
       android:id="@+id/aliasname" 
       android:layout_marginTop="10dp" 
       android:textStyle="bold" /> 

      <LinearLayout 
       android:orientation="horizontal" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:layout_marginTop="10dp"> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 

        android:text="@string/itemamount" 
        android:textColor="@color/myNavigationColor" 
        android:id="@+id/wishselling" 
        android:textStyle="bold" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 

        android:text="@string/eixstingamt" 
        android:textColor="@color/darkhash" 
        android:id="@+id/wishmrp" 
        android:layout_marginLeft="5dp" /> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 


        android:id="@+id/wishoffer" 
        android:layout_marginLeft="5dp" 
        android:textColor="@color/WishTextColor" 
        android:textStyle="bold" /> 
      </LinearLayout> 

      <LinearLayout 
       android:orientation="horizontal" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="10dp"> 

       <RatingBar 
        android:id="@+id/rtbProductRating" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:numStars="5" 
        android:rating="3" 
        android:clickable="false" 
        android:focusable="false" 
        android:focusableInTouchMode="false" 
        android:isIndicator="true" 
        android:theme="@style/RatingBar" 
        style="?android:attr/ratingBarStyleSmall" /> 
       <!-- <RatingBar android:id="@+id/ratingBar1" 
        style="@style/foodRatingBar" 

        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"> 

       </RatingBar> --> 

       <!-- style="@style/foodRatingBar" style="@style/foodRatingBar"--> 



       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:text="@string/rating" 
        android:textColor="@color/darkhash" 
        android:id="@+id/ratingtxt" 

        android:layout_marginLeft="15dp" /> 
      </LinearLayout> 

      <LinearLayout 
       android:orientation="vertical" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="5dp" 
       android:layout_marginBottom="15dp"> 

       <ImageButton 
        android:layout_width="25dp" 
        android:layout_height="25dp" 
        android:id="@+id/likes" 
        android:clickable="false" 
        android:focusable="false" 
        android:focusableInTouchMode="false" 
        android:background="@drawable/ic_delete_sweep_black_24dp" 
        android:layout_gravity="right" 
        android:layout_marginRight="15dp" /> 


      </LinearLayout> 
     </LinearLayout> 
    </LinearLayout> 
    </android.support.v7.widget.CardView> 

</LinearLayout> 

清單:

C: \Users\ admin\ AndroidStudioProjects\ shoppingdrawer\ app\ src\ main\ res\ layout\ activity_address__edit.xml 
Error: (57) Error parsing XML: duplicate attribute 
C: \Users\ admin\ AndroidStudioProjects\ shoppingdrawer\ app\ src\ main\ res\ layout\ activity_address_edit_.xml 
Error: (56) Error parsing XML: duplicate attribute 
C: \Users\ admin\ AndroidStudioProjects\ shoppingdrawer\ app\ src\ main\ res\ layout\ activity_delivery_.xml 
Error: (52) Error parsing XML: duplicate attribute 
C: \Users\ admin\ AndroidStudioProjects\ shoppingdrawer\ app\ src\ main\ res\ layout\ activity_delivery_2.xml 
Error: (52) Error parsing XML: duplicate attribute 
C: \Users\ admin\ AndroidStudioProjects\ shoppingdrawer\ app\ src\ main\ res\ layout\ addressdiplayrow.xml 
Error: (9) Error parsing XML: duplicate attribute 
C: \Users\ admin\ AndroidStudioProjects\ shoppingdrawer\ app\ src\ main\ res\ layout\ wishitemsrow.xml 
Error: (12) Error parsing XML: duplicate attribute 
Error: Execution failed 
for task ':app:processReleaseResources'. > 
    com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command ' 
C: \Users\ admin\ AppData\ Local\ Android\ sdk\ build - tools\ 23.0 .3\ aapt.exe '' 
finished with non - zero exit value 1 
Information: BUILD FAILED 
+0

你可以添加你的整個XML? – jbarat

+0

你可以添加整個xml + build.gradle(應用程序級別) –

回答

6

的問題是這兩條線:

app:cardUseCompatPadding="true" 
    card_view:cardUseCompatPadding="true" 

刪除要麼其中之一,這將是固定。

說明:儘管這兩條線似乎是不同的,他們實際上是相同的,因爲如果你看看這個:

xmlns:card_view="http://schemas.android.com/apk/res-auto" 
xmlns:app="http://schemas.android.com/apk/res-auto" 

這兩個命名空間被聲明爲同一個,這有效地意味着這兩個引用相同的事物,並且因此兩次聲明相同的屬性使其成爲重複的,這是不允許的。

+0

非常感謝,我刪除了一個,現在錯誤消失 – hem

+1

非常感謝你兄弟,我現在明白了爲什麼我在我的xml中出現這樣的錯誤。 – hem