Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Xamarin.Android.Build.Tasks] fix duplicate .aar files #8196

Merged
merged 1 commit into from
Jul 19, 2023
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 @@ -103,8 +103,9 @@ This item group populates the Build Action drop-down in IDEs.
<AndroidJavaLibrary Include="@(AndroidLibrary)" Condition=" '%(AndroidLibrary.Extension)' == '.jar' and '%(AndroidLibrary.Bind)' != 'true' " />
<EmbeddedJar Include="@(AndroidLibrary)" Condition=" '%(AndroidLibrary.Extension)' == '.jar' and '%(AndroidLibrary.Bind)' == 'true' " />
<!-- .aar files should be copied to $(OutputPath) in .NET 6-->
<None Include="@(AndroidAarLibrary)" TfmSpecificPackageFile="%(AndroidAarLibrary.Pack)" Pack="false" CopyToOutputDirectory="PreserveNewest" Link="%(Filename)%(Extension)" />
<None Include="@(LibraryProjectZip)" TfmSpecificPackageFile="%(LibraryProjectZip.Pack)" Pack="false" CopyToOutputDirectory="PreserveNewest" Link="%(Filename)%(Extension)" />
<None Include="@(AndroidLibrary)" Condition=" '%(AndroidLibrary.Extension)' == '.aar' " TfmSpecificPackageFile="%(AndroidLibrary.Pack)" Pack="false" CopyToOutputDirectory="PreserveNewest" Link="%(Filename)%(Extension)" />
<!-- @(LibraryProjectZip) items that are not in @(AndroidLibrary) -->
<None Include="@(LibraryProjectZip)" Exclude="@(AndroidLibrary)" TfmSpecificPackageFile="%(LibraryProjectZip.Pack)" Pack="false" CopyToOutputDirectory="PreserveNewest" Link="%(Filename)%(Extension)" />
</ItemGroup>
<!-- Legacy binding projects -->
<ItemGroup Condition=" '$(_AndroidIsBindingProject)' == 'true' and '$(UsingAndroidNETSdk)' != 'true' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2577,5 +2577,38 @@ public void SimilarAndroidXAssemblyNames ([Values(true, false)] bool publishTrim
using var builder = CreateApkBuilder ();
Assert.IsTrue (builder.Build (proj), "Build should have succeeded.");
}

// Combination of class libraries that triggered the problem:
// error APT2144: invalid file path 'obj/Release/net8.0-android/lp/86.stamp'.
[Test]
public void ClassLibraryAarDependencies ()
{
var path = Path.Combine ("temp", TestName);
var material = new Package { Id = "Xamarin.Google.Android.Material", Version = "1.9.0.1" };
var libraryA = new XamarinAndroidLibraryProject {
ProjectName = "LibraryA",
Sources = {
new BuildItem.Source ("Bar.cs") {
TextContent = () => "public class Bar { }",
},
},
PackageReferences = { material },
};
using var builderA = CreateDllBuilder (Path.Combine (path, libraryA.ProjectName));
Assert.IsTrue (builderA.Build (libraryA), "Build should have succeeded.");

var libraryB = new XamarinAndroidLibraryProject {
ProjectName = "LibraryB",
Sources = {
new BuildItem.Source ("Foo.cs") {
TextContent = () => "public class Foo : Bar { }",
}
},
PackageReferences = { material },
};
libraryB.AddReference (libraryA);
using var builderB = CreateDllBuilder (Path.Combine (path, libraryB.ProjectName));
Assert.IsTrue (builderB.Build (libraryB), "Build should have succeeded.");
}
}
}