Better way of declaring Custom View Attributes

How do you define you Custom View attributes? From my search, most people declared them in such that could potential cause conflict as below

Error:Execution failed for task ‘...: Error: Found item Attr/<your attribute> more than one time

Background

To make a custom view, we’ll usually want to add attributes so we could customize the view properties from the XML. A good reference about it surprisingly found below

Conventional way of Declaration

Normally below is the style used to declare e.g.

<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="CustomView">
<attr name="customAttr" format="integer" />
</declare-styleable>
</resources>

Imagine if you have two custom views, most likely you’ll declare it as below… (assuming you want the same customAttr for both views)

<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="CustomViewA">

--

--