Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ public void MergeLibraryManifest ()
android:authorities='${applicationId}.FacebookInitProvider'
android:name='.internal.FacebookInitProvider'
android:exported='false' />
<meta-data android:name='android.support.VERSION' android:value='25.4.0' />
<meta-data android:name='android.support.VERSION' android:value='25.4.0' />
</application>
</manifest>
", encoding: System.Text.Encoding.UTF8);
Expand Down Expand Up @@ -522,6 +524,8 @@ public void MergeLibraryManifest ()
"${applicationId}.FacebookInitProvider was not replaced with com.xamarin.manifest.FacebookInitProvider");
Assert.IsTrue (manifest.Contains ("com.xamarin.test.internal.FacebookInitProvider"),
".internal.FacebookInitProvider was not replaced with com.xamarin.test.internal.FacebookInitProvider");
Assert.AreEqual (manifest.IndexOf ("meta-data", StringComparison.OrdinalIgnoreCase),
manifest.LastIndexOf ("meta-data", StringComparison.OrdinalIgnoreCase), "There should be only one meta-data element");
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,16 @@ void MergeLibraryManifest (string mergedManifest)
}
}

void RemoveDuplicateElements ()
{
var duplicates = doc.Descendants ()
.GroupBy (x => x.ToFullString ())
.SelectMany (x => x.Skip (1));
foreach (var duplicate in duplicates)
duplicate.Remove ();

}

IEnumerable<XNode> FixupNameElements(string packageName, IEnumerable<XNode> nodes)
{
foreach (var element in nodes.Select ( x => x as XElement).Where (x => x != null && ManifestAttributeFixups.ContainsKey (x.Name.LocalName))) {
Expand Down Expand Up @@ -839,6 +849,7 @@ public void Save (string filename)

public void Save (System.IO.TextWriter stream)
{
RemoveDuplicateElements ();
var ms = new MemoryStream ();
doc.Save (ms);
ms.Flush ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public static string[] GetPaths (this XDocument doc, params string[] paths)
e = e.Elements (p);
return e.Select (p => p.Value).ToArray ();
}

public static string ToFullString (this XElement element)
{
return element.ToString (SaveOptions.DisableFormatting);
}
}
}