Skip to content

Commit 33e2576

Browse files
committed
[Xamarin.Android.Build.Tasks] _CompileToDalvikWithDx invoked after modifying .cs file in a referenced library project
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=58865 In this case the problem was being caused by the fact that the AndroidManifest.xml was constantly being modified. The item <meta-data android:name="android.support.VERSION" android:value="25.4.0" /> was constantly being duplicated in manifest. As a result it was always newer and was triggering a change of build targets. So we need to double check we are NOT adding 100% duplicate values to the manifest.
1 parent bafb47c commit 33e2576

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocument.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,29 @@ void MergeLibraryManifest (string mergedManifest)
394394
doc.XPathSelectElement (string.Format ("/manifest/{0}", top.Name.LocalName));
395395
if (existing != null)
396396
// if there is existing node with the same android:name, then append contents to existing node.
397-
existing.Add (FixupNameElements (package, top.Nodes ()));
397+
MergeNodesIntoElement (existing, FixupNameElements (package, top.Nodes ()));
398398
else
399399
// otherwise, just add to the doc.
400400
doc.Root.Add (FixupNameElements (package, new XNode [] { top }));
401401
}
402402
}
403403

404+
bool AttributesMatch (XElement a, XElement b)
405+
{
406+
return a.Attributes ().All (x => b.Attribute (x.Name.LocalName).Value == x.Value); ;
407+
}
408+
409+
void MergeNodesIntoElement (XElement element, IEnumerable<XNode> nodes)
410+
{
411+
var name = AndroidXmlNamespace.GetName ("name");
412+
foreach (var node in nodes.Select (x => x as XElement)) {
413+
var existing = element.Elements (node.Name.LocalName).Any (x => AttributesMatch (x, node));
414+
if (existing)
415+
continue;
416+
element.Add (node);
417+
}
418+
}
419+
404420
IEnumerable<XNode> FixupNameElements(string packageName, IEnumerable<XNode> nodes)
405421
{
406422
foreach (var element in nodes.Select ( x => x as XElement).Where (x => x != null && ManifestAttributeFixups.ContainsKey (x.Name.LocalName))) {

0 commit comments

Comments
 (0)