Android Studio中出现重复资源错误

时间:2016-12-03 11:15:22

标签: android

我正在尝试建立与WAMP服务器的连接,但我收到此错误

  

错误消息:

     

错误:任务':app:mergeDebugResources'的执行失败。   [string / id] C:\ Grad \ app \ src \ main \ res \ values \ dimens.xml [string / id] C:\ Grad \ app \ src \ main \ res \ values \ strings.xml:错误:重复资源

这是我的styles.xml:

 <resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

  </style>

 </resources>

dimens.xml:

  <resources>
  <!-- Default screen margins, per the Android Design guidelines. -->
  <dimen name="activity_horizontal_margin">16dp</dimen>
  <dimen name="activity_vertical_margin">16dp</dimen>
  <string name="id" type="string">ID</string>
  </resources>

dimens.xml:

  <resources>
       <!-- Example customization of dimensions originally defined in     res/values/dimens.xml
          (such as screen margins) for screens with more than 820dp of     available width. This
       would include 7" and 10" devices in landscape (~960dp and ~1280dp       respectively). -->
     <dimen name="activity_horizontal_margin">64dp</dimen>

    </resources>

strings.xml(w820 db)

<resources>
<string name="app_name">Grad</string>
<string name="send">Send</string>
<string name="id" type="string">ID</string>
</resources>

3 个答案:

答案 0 :(得分:3)

它真的重复,从dimen.xml中删除

ctrl+shift+t

答案 1 :(得分:2)

只需从尺寸中移除

即可
    在dimens.xml中删除
  • <string name="id" type="string">ID</string>

  • 在strings.xml中
  • 它应该是

    <string name="my_id" type="string">ID</string>

答案 2 :(得分:0)

这意味着在 values 文件夹 xmls(dimens/styles) 中的其他地方有相同的代码行。删除另一个。然后它应该可以正常工作。