Skip to content

CheckDuplicateJavaLibraries: error XA1014: JAR library references with identical file names but different contents were found: repackaged.jar #8326

@kenneththorman

Description

@kenneththorman

Android application type

Classic Xamarin.Android (MonoAndroid12.0, etc.)

Affected platform version

VS2022 17.7.3+34024.191, Xamarin17.7.0.216, Xamarin.Android SDK13.2.1.2

Description

In an Android project referencing the following

Building the project fails with

"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."

Steps to Reproduce

  1. Create a new Android application
  2. Add the Nuget package Xamarin.AndroidX.Emoji2
  3. Add a new Jar library binding project that in the Jars folder contains the https://dl.google.com/dl/android/maven2/androidx/health/connect/connect-client/1.1.0-alpha04/connect-client-1.1.0-alpha04.aar file (Build action: LibraryProjectZip)
  4. Add the following content to Transforms/Metadata.xml
  <!--
  This sample removes the class: android.support.v4.content.AsyncTaskLoader.LoadTask:
  <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" />
  
  This sample removes the method: android.support.v4.content.CursorLoader.loadInBackground:
  <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" />
  -->
  <remove-node path="/api/package[starts-with (@name, 'androidx.health.platform')]" />
 <add-node path="/api/package[@name='androidx.health.connect.client.units']/class[@name='Length']">
<method name="compareTo" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public">
<parameter name="p0" type="java.lang.Object"/>
</method>
    </add-node>
<add-node path="/api/package[@name='androidx.health.connect.client.units']/class[@name='BloodGlucose']">
<method name="compareTo" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public">
<parameter name="p0" type="java.lang.Object"/>
</method>
</add-node>
<add-node path="/api/package[@name='androidx.health.connect.client.units']/class[@name='Mass']">
<method name="compareTo" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public">
<parameter name="p0" type="java.lang.Object"/>
</method>
</add-node>
<add-node path="/api/package[@name='androidx.health.connect.client.units']/class[@name='Energy']">
<method name="compareTo" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public">
<parameter name="p0" type="java.lang.Object"/>
</method>
</add-node>
<add-node path="/api/package[@name='androidx.health.connect.client.units']/class[@name='Percentage']">
<method name="compareTo" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public">
<parameter name="p0" type="java.lang.Object"/>
</method>
</add-node>
<add-node path="/api/package[@name='androidx.health.connect.client.units']/class[@name='Power']">
<method name="compareTo" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public">
<parameter name="p0" type="java.lang.Object"/>
</method>
</add-node>
<add-node path="/api/package[@name='androidx.health.connect.client.units']/class[@name='Pressure']">
<method name="compareTo" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public">
<parameter name="p0" type="java.lang.Object"/>
</method>
</add-node>
<add-node path="/api/package[@name='androidx.health.connect.client.units']/class[@name='Velocity']">
<method name="compareTo" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public">
<parameter name="p0" type="java.lang.Object"/>
</method>
</add-node>
<add-node path="/api/package[@name='androidx.health.connect.client.units']/class[@name='Volume']">
<method name="compareTo" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public">
<parameter name="p0" type="java.lang.Object"/>
</method>
</add-node>
<add-node path="/api/package[@name='androidx.health.connect.client.units']/class[@name='Temperature']">
<method name="compareTo" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public">
<parameter name="p0" type="java.lang.Object"/>
</method>
</add-node>

<remove-node path="/api/package[@name='androidx.health.connect.client.contracts']"/>
<remove-node path="/api/package[@name='androidx.health.connect.client.contracts']"/>
</metadata>

(The transforms may not be needed for the reproducing of this problem, but I have added them to this issue anyway, to speed up the process)
5. Reference this new Jar library binding project in the main android application
6. Build the Android application

Seems related to : #5627

Did you find any workaround?

No "nice" workaround found.
A "not-so-nice" workaround exists which requires renaming the conflicting libs/jar files and recompiling the upstream aar file.

Relevant log output

11>Target "_CheckDuplicateJavaLibraries: (TargetId:400)" in file "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets" from project "D:\Users\Appinux\projects\dialogevent_2\DialogEvent\DialogEvent.Droid\DialogEvent.Droid.csproj" (target "_UpdateAndroidResgen" depends on it):
11>Using "CheckDuplicateJavaLibraries" task from assembly "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\Xamarin.Android.Build.Tasks.dll".
11>Task "CheckDuplicateJavaLibraries" (TaskId:588)
11>  Task Parameter:
11>      JavaLibraries=
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.AndroidX.ConstraintLayout.Core.1.0.1.3\build\monoandroid90\..\..\jar\androidx.constraintlayout.constraintlayout-core.jar
11>                  AndroidXSkipAndroidXMigration=true
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.AndroidX.ConstraintLayout.Solver.2.0.4.2\build\monoandroid9.0\..\..\jar\androidx.constraintlayout.constraintlayout-solver.jar
11>                  AndroidXSkipAndroidXMigration=true
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.AndroidX.Room.Common.2.3.0.6\build\monoandroid12.0\..\..\jar\androidx.room.room-common.jar
11>                  AndroidXSkipAndroidXMigration=true
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.AndroidX.ResourceInspection.Annotation.1.0.1.2\build\monoandroid12.0\..\..\jar\androidx.resourceinspection.resourceinspection-annotation.jar
11>                  AndroidXSkipAndroidXMigration=true
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.Jetbrains.Annotations.24.0.1.1\build\monoandroid12.0\..\..\jar\org.jetbrains.annotations-24.0.1.jar
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.Kotlin.StdLib.Common.1.8.20.1\build\monoandroid12.0\..\..\jar\org.jetbrains.kotlin.kotlin-stdlib-common-1.8.20.jar
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.Kotlin.StdLib.1.8.20.1\build\monoandroid12.0\..\..\jar\org.jetbrains.kotlin.kotlin-stdlib-1.8.20.jar
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.AndroidX.Annotation.1.6.0.1\build\monoandroid12.0\..\..\jar\androidx.annotation.annotation.jar
11>                  AndroidXSkipAndroidXMigration=true
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.AndroidX.Arch.Core.Common.2.2.0.1\build\monoandroid12.0\..\..\jar\androidx.arch.core.core-common.jar
11>                  AndroidXSkipAndroidXMigration=true
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.AndroidX.Collection.1.2.0.7\build\monoandroid12.0\..\..\jar\androidx.collection.collection.jar
11>                  AndroidXSkipAndroidXMigration=true
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.AndroidX.Concurrent.Futures.1.1.0.12\build\monoandroid12.0\..\..\jar\androidx.concurrent.concurrent-futures.jar
11>                  AndroidXSkipAndroidXMigration=true
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.Kotlin.StdLib.Jdk7.1.8.20.1\build\monoandroid12.0\..\..\jar\org.jetbrains.kotlin.kotlin-stdlib-jdk7-1.8.20.jar
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.Kotlin.StdLib.Jdk8.1.8.20.1\build\monoandroid12.0\..\..\jar\org.jetbrains.kotlin.kotlin-stdlib-jdk8-1.8.20.jar
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.KotlinX.Coroutines.Core.Jvm.1.6.4.3\build\monoandroid12.0\..\..\jar\org.jetbrains.kotlinx.kotlinx-coroutines-core-jvm-1.6.4.jar
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.KotlinX.Coroutines.Android.1.6.4.3\build\monoandroid12.0\..\..\jar\org.jetbrains.kotlinx.kotlinx-coroutines-android-1.6.4.jar
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.AndroidX.Lifecycle.Common.2.6.1.1\build\monoandroid12.0\..\..\jar\androidx.lifecycle.lifecycle-common.jar
11>                  AndroidXSkipAndroidXMigration=true
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.Android.Google.Code.Gson.2.8.8\build\..\jar\com.google.code.gson.gson.jar
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.CheckerFramework.CheckerQual.3.34.0.1\build\monoandroid12.0\..\..\jar\checker-qual.jar
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.Google.Guava.FailureAccess.1.0.1.11\build\monoandroid12.0\..\..\jar\guava-failureaccess.jar
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.Google.J2Objc.Annotations.2.8.0.3\build\monoandroid12.0\..\..\jar\j2objc-annotations.jar
11>          D:\Users\Appinux\projects\dialogevent_2\DialogEvent\packages\Xamarin.Google.Guava.31.1.0.7\build\monoandroid12.0\..\..\jar\guava.jar (TaskId:588)
11>  Task Parameter:
11>      LibraryProjectJars=
11>          obj\Debug\130\lp\0\jl\androidsvg-1.2.1.jar
11>          obj\Debug\130\lp\1\jl\bin\classes.jar
11>          obj\Debug\130\lp\10\jl\fm.video.jar
11>          obj\Debug\130\lp\100\jl\firebase-encoders-proto.jar
11>          obj\Debug\130\lp\101\jl\bin\classes.jar
11>          obj\Debug\130\lp\102\jl\bin\classes.jar
11>          obj\Debug\130\lp\103\jl\bin\classes.jar
11>          obj\Debug\130\lp\104\jl\bin\classes.jar
11>          obj\Debug\130\lp\105\jl\bin\classes.jar
11>          obj\Debug\130\lp\106\jl\bin\classes.jar
11>          obj\Debug\130\lp\107\jl\bin\classes.jar
11>          obj\Debug\130\lp\108\jl\bin\classes.jar
11>          obj\Debug\130\lp\109\jl\bin\classes.jar
11>          obj\Debug\130\lp\11\jl\GraphView-4.0.0.jar
11>          obj\Debug\130\lp\111\jl\auto-value-annotations.jar
11>          obj\Debug\130\lp\113\jl\error_prone_annotations.jar
11>          obj\Debug\130\lp\116\jl\bin\classes.jar
11>          obj\Debug\130\lp\117\jl\bin\classes.jar
11>          obj\Debug\130\lp\118\jl\bin\classes.jar
11>          obj\Debug\130\lp\119\jl\bin\classes.jar
11>          obj\Debug\130\lp\12\jl\bin\classes.jar
11>          obj\Debug\130\lp\120\jl\bin\classes.jar
11>          obj\Debug\130\lp\121\jl\javax.inject.jar
11>          obj\Debug\130\lp\126\jl\bin\classes.jar
11>          obj\Debug\130\lp\127\jl\bin\classes.jar
11>          obj\Debug\130\lp\127\jl\libs\ogsccommunicationlibrary.jar
11>          obj\Debug\130\lp\127\jl\libs\soniccommunicationlibrary.jar
11>          obj\Debug\130\lp\128\jl\bin\classes.jar
11>          obj\Debug\130\lp\128\jl\libs\repackaged.jar   <---------------------- Emoji2
11>          obj\Debug\130\lp\129\jl\classes.jar
11>          obj\Debug\130\lp\13\jl\jsr305.jar
11>          obj\Debug\130\lp\130\jl\classes.jar
11>          obj\Debug\130\lp\131\jl\classes.jar
11>          obj\Debug\130\lp\132\jl\classes.jar
11>          obj\Debug\130\lp\133\jl\classes.jar
11>          obj\Debug\130\lp\134\jl\classes.jar
11>          obj\Debug\130\lp\135\jl\classes.jar
11>          obj\Debug\130\lp\136\jl\classes.jar
11>          obj\Debug\130\lp\137\jl\classes.jar
11>          obj\Debug\130\lp\138\jl\classes.jar
11>          obj\Debug\130\lp\139\jl\classes.jar
11>          obj\Debug\130\lp\140\jl\classes.jar
11>          obj\Debug\130\lp\141\jl\classes.jar
11>          obj\Debug\130\lp\142\jl\classes.jar
11>          obj\Debug\130\lp\143\jl\classes.jar
11>          obj\Debug\130\lp\144\jl\classes.jar
11>          obj\Debug\130\lp\145\jl\classes.jar
11>          obj\Debug\130\lp\146\jl\classes.jar
11>          obj\Debug\130\lp\147\jl\classes.jar
11>          obj\Debug\130\lp\148\jl\classes.jar
11>          obj\Debug\130\lp\149\jl\classes.jar
11>          obj\Debug\130\lp\150\jl\classes.jar
11>          obj\Debug\130\lp\151\jl\classes.jar
11>          obj\Debug\130\lp\152\jl\classes.jar
11>          obj\Debug\130\lp\153\jl\classes.jar
11>          obj\Debug\130\lp\154\jl\classes.jar
11>          obj\Debug\130\lp\155\jl\classes.jar
11>          obj\Debug\130\lp\156\jl\classes.jar
11>          obj\Debug\130\lp\157\jl\classes.jar
11>          obj\Debug\130\lp\157\jl\libs\repackaged.jar   <---------------------- connect-client1.1-alpha04
11>          obj\Debug\130\lp\158\jl\classes.jar
11>          obj\Debug\130\lp\159\jl\classes.jar
11>          obj\Debug\130\lp\160\jl\classes.jar
11>          obj\Debug\130\lp\161\jl\classes.jar
11>          obj\Debug\130\lp\162\jl\classes.jar
11>          obj\Debug\130\lp\163\jl\classes.jar
11>          obj\Debug\130\lp\164\jl\classes.jar
11>          obj\Debug\130\lp\165\jl\classes.jar
11>          obj\Debug\130\lp\166\jl\classes.jar
11>          obj\Debug\130\lp\167\jl\classes.jar
11>          obj\Debug\130\lp\168\jl\classes.jar
11>          obj\Debug\130\lp\169\jl\classes.jar
11>          obj\Debug\130\lp\170\jl\classes.jar
11>          obj\Debug\130\lp\171\jl\classes.jar
11>          obj\Debug\130\lp\172\jl\classes.jar
11>          obj\Debug\130\lp\173\jl\classes.jar
11>          obj\Debug\130\lp\174\jl\classes.jar
11>          obj\Debug\130\lp\175\jl\classes.jar
11>          obj\Debug\130\lp\176\jl\classes.jar
11>          obj\Debug\130\lp\177\jl\classes.jar
11>          obj\Debug\130\lp\178\jl\classes.jar
11>          obj\Debug\130\lp\179\jl\classes.jar
11>          obj\Debug\130\lp\180\jl\classes.jar
11>          obj\Debug\130\lp\181\jl\classes.jar
11>          obj\Debug\130\lp\182\jl\classes.jar
11>          obj\Debug\130\lp\183\jl\classes.jar
11>          obj\Debug\130\lp\184\jl\classes.jar
11>          obj\Debug\130\lp\185\jl\classes.jar
11>          obj\Debug\130\lp\186\jl\classes.jar
11>          obj\Debug\130\lp\187\jl\classes.jar
11>          obj\Debug\130\lp\188\jl\classes.jar
11>          obj\Debug\130\lp\189\jl\classes.jar
11>          obj\Debug\130\lp\190\jl\classes.jar
11>          obj\Debug\130\lp\191\jl\classes.jar
11>          obj\Debug\130\lp\192\jl\classes.jar
11>          obj\Debug\130\lp\193\jl\classes.jar
11>          obj\Debug\130\lp\194\jl\classes.jar
11>          obj\Debug\130\lp\195\jl\classes.jar
11>          obj\Debug\130\lp\196\jl\classes.jar
11>          obj\Debug\130\lp\197\jl\classes.jar
11>          obj\Debug\130\lp\198\jl\classes.jar
11>          obj\Debug\130\lp\199\jl\classes.jar
11>          obj\Debug\130\lp\200\jl\classes.jar
11>          obj\Debug\130\lp\22\jl\bin\classes.jar
11>          obj\Debug\130\lp\26\jl\libspiromagic0_6_targetsdk29.jar
11>          obj\Debug\130\lp\27\jl\library-1.0.19.jar
11>          obj\Debug\130\lp\28\jl\commons-math3-3.6.1.jar
11>          obj\Debug\130\lp\5\jl\bin\classes.jar
11>          obj\Debug\130\lp\6\jl\fm.audio.jar
11>          obj\Debug\130\lp\94\jl\firebase-annotations.jar
11>          obj\Debug\130\lp\95\jl\bin\classes.jar
11>          obj\Debug\130\lp\96\jl\bin\classes.jar
11>          obj\Debug\130\lp\97\jl\bin\classes.jar
11>          obj\Debug\130\lp\98\jl\firebase-encoders.jar
11>          obj\Debug\130\lp\99\jl\bin\classes.jar (TaskId:588)
11>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(871,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.
11>Done executing task "CheckDuplicateJavaLibraries" -- FAILED. (TaskId:588)
11>Done building target "_CheckDuplicateJavaLibraries" in project "DialogEvent.Droid.csproj" -- FAILED.: (TargetId:400)

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions