Repository navigation
False negative warning for valid meta-data #1929
Description
Activity
also: the warning is ... bad :D a malformed WHAT has been found? :D
It is okay, we print the name of the meta-data element (which is this weird thing in this case).
yeah but still i think the warning should contain the element type in some way.
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_PATHSOh. Okay. :)
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?
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).
@dodgex i think
MetadataInfois okay. Normally we should only break API in major version, but i think we can do it in this case in a minor version.@WonderCsabo Yeah. I think you are right.
@smaugho feel free to contribute a fix :)
implemented
AA cannot parse a valid meta-data element from the manifest, like this:
It emits the following warning:
This is a valid meta-data, so we should be able to parse it.