diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/CheckDuplicateJavaLibraries.cs b/src/Xamarin.Android.Build.Tasks/Tasks/CheckDuplicateJavaLibraries.cs
index 2f7f199111c..5739e3cf40d 100644
--- a/src/Xamarin.Android.Build.Tasks/Tasks/CheckDuplicateJavaLibraries.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tasks/CheckDuplicateJavaLibraries.cs
@@ -9,16 +9,12 @@ namespace Xamarin.Android.Tasks
{
public class CheckDuplicateJavaLibraries : AndroidTask
{
- readonly static string [] ExcludedFiles = new [] {
- "classes.jar",
- "r-classes.jar",
- };
-
public override string TaskPrefix => "CDJ";
public ITaskItem [] JavaSourceFiles { get; set; }
public ITaskItem[] JavaLibraries { get; set; }
public ITaskItem[] LibraryProjectJars { get; set; }
+ public string [] ExcludedFiles { get; set; }
public override bool RunTask ()
{
diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs
index 66a14fe783b..d4e24312561 100644
--- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs
@@ -722,31 +722,45 @@ public void LibraryProjectZipWithLint ()
}
///
- /// Tests two .aar files with r-classes.jar
+ /// Tests two .aar files with r-classes.jar, repackaged.jar
///
[Test]
- public void AarWithRClassesJar ()
+ public void CheckDuplicateJavaLibraries ()
{
var path = Path.Combine ("temp", TestName);
var lib1 = new XamarinAndroidBindingProject {
ProjectName = "Library1",
AndroidClassParser = "class-parse",
Jars = {
+ // r-classes.jar
new AndroidItem.LibraryProjectZip ("Library1.aar") {
BinaryContent = () => ResourceData.Library1Aar
- }
+ },
+ // repackaged.jar
+ new AndroidItem.AndroidLibrary ("emoji2-1.4.0.aar") {
+ MetadataValues = "Bind=false",
+ WebContent = "https://maven.google.com/androidx/emoji2/emoji2/1.4.0/emoji2-1.4.0.aar",
+ },
},
};
var lib2 = new XamarinAndroidBindingProject {
ProjectName = "Library2",
AndroidClassParser = "class-parse",
Jars = {
+ // r-classes.jar
new AndroidItem.LibraryProjectZip ("Library2.aar") {
BinaryContent = () => ResourceData.Library2Aar
- }
+ },
+ // repackaged.jar
+ new AndroidItem.AndroidLibrary ("connect-client-1.1.0-alpha07.aar") {
+ MetadataValues = "Bind=false",
+ WebContent = "https://maven.google.com/androidx/health/connect/connect-client/1.1.0-alpha07/connect-client-1.1.0-alpha07.aar",
+ },
},
};
- var app = new XamarinAndroidApplicationProject ();
+ var app = new XamarinAndroidApplicationProject {
+ SupportedOSPlatformVersion = "30", // androidx.health requires minSdkVersion="30"
+ };
app.AddReference (lib1);
app.AddReference (lib2);
using (var lib1Builder = CreateDllBuilder (Path.Combine (path, lib1.ProjectName)))
diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
index ee44ddd2bf2..ec146d544bd 100644
--- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
+++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
@@ -843,10 +843,17 @@ because xbuild doesn't support framework reference assemblies.
+
+ <_AndroidExcludedDuplicateJavaLibraries Include="classes.jar" />
+ <_AndroidExcludedDuplicateJavaLibraries Include="r-classes.jar" />
+ <_AndroidExcludedDuplicateJavaLibraries Include="repackaged.jar" />
+
+ LibraryProjectJars="@(ExtractedJarImports)"
+ ExcludedFiles="@(_AndroidExcludedDuplicateJavaLibraries)"
+ />