def get_rpath_attribute(root, element_path, attribute, default=None):
    """Returns the value of an attribute at an rpath.

    If more than one element exists with the same name, only the first is
    checked.

    Args:
        root: The XML element to search from.
        path: The path to the element.
        attribute: The name of the attribute to fetch.

    Returns:
        The attribute's value as a string if found, else the value of
        `default`.
    """
    ns_url = 'http://schemas.android.com/apk/res/android'
    ns = {
        'android': ns_url,
    }

    elem = root.find(element_path, ns)
    if elem is None:
        return ''
    # ElementTree elements don't have the same helpful namespace parameter that
    # the find family does :(
    attrib_name = attribute.replace('android:', '{' + ns_url + '}')
    return elem.get(attrib_name, default)