title: Duplicate resources: how do android namespace in layouts, customviews and attributes work?
body: <p>According to <a href="https://developer.android.com/training/custom-views/create-view" rel="nofollow noreferrer">Google training docs on custom views</a>,</p>
  <blockquote>
  <p>Once you define the custom attributes, you can use them in layout XML
  files just like built-in attributes. The only difference is that your
  custom attributes belong to a different namespace.</p>
  </blockquote>
  <p>But I am getting a &quot;Error: Duplicate resources&quot; when I try to use this.
  My layout file looks like:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
          xmlns:tools=&quot;http://schemas.android.com/tools&quot;
          xmlns:searchview=&quot;http://schemas.android.com
      /apk/com.kana_tutor.kana_utils.SearchView&quot;
          xmlns:simplespinner=&quot;http://schemas.android.com
      /apk/com.kana_tutor.kana_utils.SimpleSpinner&quot;
           ...&gt;
      
          &lt;com.kana_tutor.kana_utils.SearchView
            ...
              searchview:textColor=&quot;/@color/red&quot;
              /&gt;
      
          &lt;com.kana_tutor.kana_utils.SimpleSpinner
              ...
              simplespinner:textColor=&quot;@color/textview_background&quot;
              /&gt;
          ...
  </code></pre>
  <p>I put the attributes in two separate files:
  searchview_attrs.xml:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;resources&gt;
      &lt;declare-styleable name=&quot;SearchView&quot;&gt;
          &lt;attr name=&quot;textColor&quot; format = &quot;reference&quot; /&gt;
      &lt;/declare-styleable&gt;
  &lt;/resources&gt;
  </code></pre>
  <p>simplespinners_attrs:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;resources&gt;
      &lt;declare-styleable name=&quot;simplespinner&quot;&gt;
          &lt;attr name=&quot;textColor&quot; format = &quot;reference|string&quot; /&gt;
      &lt;/declare-styleable&gt;
  &lt;/resources&gt;
  </code></pre>
  <p>But the IDE says:</p>
  <blockquote>
  <p>[attr/textColor] /.../simplespinner_attrs.xml [attr/textColor]
  /.../searchview_attrs.xml: Error: Duplicate resources</p>
  </blockquote>
  <p>As I read the docs, I should be able to have sAm I misunderstanding &quot;belong to a different namespace&quot; or is there something wrong with my code?</p>