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] <CheckDuplicateJavaLibraries/> ignores repackaged.jar #8664

Merged

Conversation

jonathanpeppers
Copy link
Member

Context: https://maven.google.com/androidx/emoji2/emoji2/1.4.0/emoji2-1.4.0.aar
Context: https://maven.google.com/androidx/health/connect/connect-client/1.1.0-alpha07/connect-client-1.1.0-alpha07.aar

When using the two AARs linked above, you get the build error:

Xamarin.Android.Common.targets(845,3): error XA1014: JAR library references with identical file names but different contents were found: repackaged.jar. Please remove any conflicting libraries from EmbeddedJar, InputJar and AndroidJavaLibrary.

They both contain libs/repackaged.jar, which I'm not able to find any information about. I can reproduce this problem in an MSBuild test.

Unfortunately, the only way to workaround the error message is to:

  • Unzip the .aar

  • Rename libs/repackaged.jar to libs/repackaged-emoji2-1.4.0.jar, for example

  • Re-zip the .aar

a9ca3d4 had a similar problem with r-classes.jar. Let's expand upon this change by introducing a private item group:

<ItemGroup>
  <_AndroidExcludedDuplicateJavaLibraries Include="classes.jar" />
  <_AndroidExcludedDuplicateJavaLibraries Include="r-classes.jar" />
  <_AndroidExcludedDuplicateJavaLibraries Include="repackaged.jar" />
</ItemGroup>

So if this occurs in the future, we can add future files to this list without rebuilding the Android workload.

…s `repackaged.jar`

Context: https://maven.google.com/androidx/emoji2/emoji2/1.4.0/emoji2-1.4.0.aar
Context: https://maven.google.com/androidx/health/connect/connect-client/1.1.0-alpha07/connect-client-1.1.0-alpha07.aar

When using the two AARs linked above, you get the build error:

    Xamarin.Android.Common.targets(845,3): error XA1014: JAR library references with identical file names but different contents were found: repackaged.jar. Please remove any conflicting libraries from EmbeddedJar, InputJar and AndroidJavaLibrary.

They both contain `libs/repackaged.jar`, which I'm not able to find any
information about. I can reproduce this problem in an MSBuild test.

Unfortunately, the only way to workaround the error message is to:

* Unzip the `.aar`

* Rename `libs/repackaged.jar` to `libs/repackaged-emoji2-1.4.0.jar`,
  for example

* Re-zip the `.aar`

a9ca3d4 had a similar problem with `r-classes.jar`. Let's expand upon
this change by introducing a private item group:

    <ItemGroup>
      <_AndroidExcludedDuplicateJavaLibraries Include="classes.jar" />
      <_AndroidExcludedDuplicateJavaLibraries Include="r-classes.jar" />
      <_AndroidExcludedDuplicateJavaLibraries Include="repackaged.jar" />
    </ItemGroup>

So if this occurs in the future, we can add future files to this list
without rebuilding the Android workload.
@jonathanpeppers jonathanpeppers merged commit 2cbb5c9 into xamarin:main Jan 23, 2024
47 checks passed
@jonathanpeppers jonathanpeppers deleted the CheckDuplicateJavaLibraries branch January 23, 2024 22:04
grendello added a commit that referenced this pull request Jan 24, 2024
* main:
  [Xamarin.Android.build.Tasks] `<CheckDuplicateJavaLibraries/>` ignores `repackaged.jar` (#8664)
jonathanpeppers added a commit that referenced this pull request Jan 25, 2024
…s `repackaged.jar` (#8664)

Context: https://maven.google.com/androidx/emoji2/emoji2/1.4.0/emoji2-1.4.0.aar
Context: https://maven.google.com/androidx/health/connect/connect-client/1.1.0-alpha07/connect-client-1.1.0-alpha07.aar

When using the two AARs linked above, you get the build error:

    Xamarin.Android.Common.targets(845,3): error XA1014: JAR library references with identical file names but different contents were found: repackaged.jar. Please remove any conflicting libraries from EmbeddedJar, InputJar and AndroidJavaLibrary.

They both contain `libs/repackaged.jar`, which I'm not able to find any
information about. I can reproduce this problem in an MSBuild test.

Unfortunately, the only way to workaround the error message is to:

* Unzip the `.aar`

* Rename `libs/repackaged.jar` to `libs/repackaged-emoji2-1.4.0.jar`,
  for example

* Re-zip the `.aar`

a9ca3d4 had a similar problem with `r-classes.jar`. Let's expand upon
this change by introducing a private item group:

    <ItemGroup>
      <_AndroidExcludedDuplicateJavaLibraries Include="classes.jar" />
      <_AndroidExcludedDuplicateJavaLibraries Include="r-classes.jar" />
      <_AndroidExcludedDuplicateJavaLibraries Include="repackaged.jar" />
    </ItemGroup>

So if this occurs in the future, we can add future files to this list
without rebuilding the Android workload.
grendello added a commit that referenced this pull request Jan 25, 2024
* main:
  Localized file check-in by OneLocBuild Task (#8668)
  [Xamarin.Android.build.Tasks] `<CheckDuplicateJavaLibraries/>` ignores `repackaged.jar` (#8664)
  LEGO: Merge pull request 8665
  [Xamarin.Android.Build.Tasks] parse JDK `release` file directly (#8663)
  Bump to dotnet/installer@f91d4ca399 9.0.100-alpha.1.24070.3 (#8635)
  [.github] Re-enable locking issues after 30 days of inactivity (#8655)
  Localized file check-in by OneLocBuild Task (#8657)
  LEGO: Merge pull request 8656
  Localized file check-in by OneLocBuild Task (#8652)
  Bump to xamarin/xamarin-android-tools/main@b175674 (#8644)
  [Xamarin.Android.Build.Tasks] remove checks for `$(UsingAndroidNETSdk)` (#8647)
  [Xamarin.Android.Build.Tasks] XA1039 error for Android.Support (#8629)
jonpryor pushed a commit that referenced this pull request Feb 2, 2024
Context: fd47b02
Context: https://dotnet.microsoft.com/platform/support/policy/maui

Changes: d12da3a...87e4a6d

  * 87e4a6d89: [release/8.0.1xx] localization changes for `XA1039` (#8674)
  * f61c76030: [workload] Allow installation on linux-arm64 (#8500)
  * 4cdf1e018: [Xamarin.Android.build.Tasks] `<CheckDuplicateJavaLibraries/>` ignores `repackaged.jar` (#8664)
  * 77ac82a11: [release/8.0.1xx] [Xamarin.Android.Build.Tasks] XA1039 warning for Android.Support (#8648)
  * c22c17fbe: [Xamarin.Android.Build.Tasks] fix warning when missing `proguard-android.txt` (#8641)
  * 31f031a67: Localized file check-in by OneLocBuild Task (#8643)
  * 3da479192: LEGO: Merge pull request 8642
  * dbf100d49: Update a number of l18n files (#8633)
  * d2da5bf4e: Bump com.android.tools:r8 from 8.1.72 to 8.2.33 (#8577)
  * 9f9114afc: Bump com.android.tools:r8 from 8.1.56 to 8.1.72 (#8532)
  * 666777248: Fix ServerCertificateCustomValidator on API 21-23 (#8637)
  * 940f059b8: [Mono.Android] Fix ServerCertificateCustomValidator (#8594)
  * 351bfa3f0: Bump to dotnet/runtime@a6e4834d53 8.0.1 (#8616)
  * 64363367d: [Microsoft.Android.Templates] New files should open editor (#8623)
  * 26752564d: Bump to dotnet/installer@461c776642 8.0.101-servicing.23614.6
  * 6972027f0: Localized file check-in by OneLocBuild Task (#8589)
  * 73efcfcad: [Xamarin.Android.Buid.Tasks] don't set $(PublishSelfContained) for .NET 9 (#8565)
  * 3333306b8: LEGO: Merge pull request 8587
  * 38e950b41: Localized file check-in by OneLocBuild Task (#8576)
  * 607115fd5: LEGO: Merge pull request 8575
  * a1fd1b2cb: Localized file check-in by OneLocBuild Task (#8570)
  * c020626b0: [Xamarin.Android.Build.Tasks] Update XA5207 for VSCode (#8494)
  * b0aab545a: Bump to dotnet/installer@822071c28a 8.0.101-servicing.23578.14 (#8558)


The .NET MAUI Support policy, which covers .NET Android, states:

> A major version of .NET MAUI receives support for a minimum of 6
> months after a successor (the next major release) ships.

meaning that a given version of .NET Android only needs to support
building `$(TargetFramework)` values for the current .NET Android
version and the previous .NET Android version.

Meanwhlie, from fd47b02:

> We currently have a hard dependency between:
> 
>   * `Xamarin.Android.Build.Tasks.dll`
>   * `libmonodroid.so`

…in order to safely build projects targeting the previous .NET Android
version with the current .NET Android version, the current .NET Android
version workload *includes the previous workload version contents*.

The `$(AndroidNetPreviousVersion)` MSBuild property specifies the
.NET Android SDK version, as obtained from `dotnet workllad list`,
which should be used to build previous `$(TargetFramework)` versions.

`$(AndroidNetPreviousVersion)` should be updated in
xamarin-android/main whenever a .NET servicing release for the previous
.NET version is shipped.

.NET Android 34.0.79 will be shipped as part of .NET 8.0.2.
Update `$(AndroidNetPreviousVersion)` to so that .NET 9 previews use
the latest .NET 8 workload contents.
jonathanpeppers added a commit that referenced this pull request Feb 2, 2024
Context: fd47b02
Context: https://dotnet.microsoft.com/platform/support/policy/maui

Changes: d12da3a...87e4a6d

  * 87e4a6d89: [release/8.0.1xx] localization changes for `XA1039` (#8674)
  * f61c76030: [workload] Allow installation on linux-arm64 (#8500)
  * 4cdf1e018: [Xamarin.Android.build.Tasks] `<CheckDuplicateJavaLibraries/>` ignores `repackaged.jar` (#8664)
  * 77ac82a11: [release/8.0.1xx] [Xamarin.Android.Build.Tasks] XA1039 warning for Android.Support (#8648)
  * c22c17fbe: [Xamarin.Android.Build.Tasks] fix warning when missing `proguard-android.txt` (#8641)
  * 31f031a67: Localized file check-in by OneLocBuild Task (#8643)
  * 3da479192: LEGO: Merge pull request 8642
  * dbf100d49: Update a number of l18n files (#8633)
  * d2da5bf4e: Bump com.android.tools:r8 from 8.1.72 to 8.2.33 (#8577)
  * 9f9114afc: Bump com.android.tools:r8 from 8.1.56 to 8.1.72 (#8532)
  * 666777248: Fix ServerCertificateCustomValidator on API 21-23 (#8637)
  * 940f059b8: [Mono.Android] Fix ServerCertificateCustomValidator (#8594)
  * 351bfa3f0: Bump to dotnet/runtime@a6e4834d53 8.0.1 (#8616)
  * 64363367d: [Microsoft.Android.Templates] New files should open editor (#8623)
  * 26752564d: Bump to dotnet/installer@461c776642 8.0.101-servicing.23614.6
  * 6972027f0: Localized file check-in by OneLocBuild Task (#8589)
  * 73efcfcad: [Xamarin.Android.Buid.Tasks] don't set $(PublishSelfContained) for .NET 9 (#8565)
  * 3333306b8: LEGO: Merge pull request 8587
  * 38e950b41: Localized file check-in by OneLocBuild Task (#8576)
  * 607115fd5: LEGO: Merge pull request 8575
  * a1fd1b2cb: Localized file check-in by OneLocBuild Task (#8570)
  * c020626b0: [Xamarin.Android.Build.Tasks] Update XA5207 for VSCode (#8494)
  * b0aab545a: Bump to dotnet/installer@822071c28a 8.0.101-servicing.23578.14 (#8558)


The .NET MAUI Support policy, which covers .NET Android, states:

> A major version of .NET MAUI receives support for a minimum of 6
> months after a successor (the next major release) ships.

meaning that a given version of .NET Android only needs to support
building `$(TargetFramework)` values for the current .NET Android
version and the previous .NET Android version.

Meanwhlie, from fd47b02:

> We currently have a hard dependency between:
> 
>   * `Xamarin.Android.Build.Tasks.dll`
>   * `libmonodroid.so`

…in order to safely build projects targeting the previous .NET Android
version with the current .NET Android version, the current .NET Android
version workload *includes the previous workload version contents*.

The `$(AndroidNetPreviousVersion)` MSBuild property specifies the
.NET Android SDK version, as obtained from `dotnet workllad list`,
which should be used to build previous `$(TargetFramework)` versions.

`$(AndroidNetPreviousVersion)` should be updated in
xamarin-android/main whenever a .NET servicing release for the previous
.NET version is shipped.

.NET Android 34.0.79 will be shipped as part of .NET 8.0.2.
Update `$(AndroidNetPreviousVersion)` to so that .NET 9 previews use
the latest .NET 8 workload contents.
@github-actions github-actions bot locked and limited conversation to collaborators Feb 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants