Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

False negative warning for valid meta-data #1929

Description

@WonderCsabo

AA cannot parse a valid meta-data element from the manifest, like this:

<meta-data
                android:name="com.commonsware.cwac.provider.STREAM_PROVIDER_PATHS"
                android:resource="@xml/file_paths"/>

It emits the following warning:

warning: A malformed <meta-data> has been found in the manifest with name com.commonsware.cwac.provider.STREAM_PROVIDER_PATHS

This is a valid meta-data, so we should be able to parse it.

Activity

  1. dodgex commented on Jan 4, 2017

    @dodgex
    Member

    also: the warning is ... bad :D a malformed WHAT has been found? :D

  2. WonderCsabo commented on Jan 4, 2017

    @WonderCsabo
    MemberAuthor

    It is okay, we print the name of the meta-data element (which is this weird thing in this case).

  3. dodgex commented on Jan 4, 2017

    @dodgex
    Member

    yeah but still i think the warning should contain the element type in some way.

  4. WonderCsabo commented on Jan 4, 2017

    @WonderCsabo
    MemberAuthor

    Oh, the message is correct, just Github removed <meta-data>. :)

    This is the full message

    warning: A malformed <meta-data> has been found in the manifest with name com.commonsware.cwac.provider.STREAM_PROVIDER_PATHS
    
  5. dodgex commented on Jan 4, 2017

    @dodgex
    Member

    Oh. Okay. :)

  6. smaugho commented on Jan 7, 2017

    @smaugho
    Contributor

    The problem is that I assumed that always it should have a "value" field, and this is not true. This is the code:

            private Map<String, String> extractMetaDataQualifiedNames(NodeList metaDataNodes) {
    		Map<String, String> metaDataQualifiedNames = new HashMap<String, String>();
    		
    		for (int i = 0; i < metaDataNodes.getLength(); i++) {
    			Node node = metaDataNodes.item(i);
    			Node nameAttribute = node.getAttributes().getNamedItem("android:name");
    			Node valueAttribute = node.getAttributes().getNamedItem("android:value");
    
    			if (nameAttribute == null || valueAttribute == null) {
    				if (nameAttribute != null) {
    					LOGGER.warn("A malformed <meta-data> has been found in the manifest with name {}", nameAttribute.getNodeValue());
    				} else {
    					LOGGER.warn("A malformed <meta-data> has been found in the manifest");
    				}
    			} else {
    				metaDataQualifiedNames.put(nameAttribute.getNodeValue(), valueAttribute.getNodeValue());
    			}
    		}
    		
    		return metaDataQualifiedNames;
    	}

    I will try to make it generic.. Now following the correct syntax for the meta-data tag:

        <meta-data android:name="string"
                   android:resource="resource specification"
                   android:value="string" />
    

    The method should be able to recollect not only the Value, but also the resource... But all these methods return a Map<String, String>.... so key-value...

    Maybe it would be good to save a Map<String, MetaDataInfo> with MetaData info containing both Value and Resource.

    Any suggestion?

  7. smaugho commented on Jan 11, 2017

    @smaugho
    Contributor

    Hi @dodgex , @WonderCsabo about this functionality, I would like to know if for you is ok to implemente it like I suggested, I was the one that implemente it only taking in Account the value (well to be honest, didn't need the resource in that specific moment).. but to make it more generic, and avoid this error that you are reporting, then a Structure should be used in the Map, I just would like to agree with you about if it is the correct way, and please if you could suggest me where to place this Structure (the class I called MetaDataInfo above).

  8. WonderCsabo commented on Jan 13, 2017

    @WonderCsabo
    MemberAuthor

    @dodgex i think MetadataInfo is okay. Normally we should only break API in major version, but i think we can do it in this case in a minor version.

  9. dodgex commented on Jan 13, 2017

    @dodgex
    Member

    @WonderCsabo Yeah. I think you are right.

    @smaugho feel free to contribute a fix :)

  10. dodgex commented on Feb 20, 2017

    @dodgex
    Member

    implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions