After adding the packages of "Xamarin.Firebase.Messaging", getting error related to JAVA0000 "Compilation failed"

31 Views Asked by At

I need to implement Firebase push notification, so I added the packages of latest version into my Maui .net8.0 project. Here are the packages added in csproj file for push notifications. I'm getting error when I upgraded to the latest version of these packages related to error- JAVA0000.

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">

<GoogleServicesJson Include="google-services.json" />

<PackageReference Include="Xamarin.Firebase.Dynamic.Links">
    <Version>121.2.0.2</Version>
</PackageReference>
<PackageReference Include="Xamarin.Firebase.Messaging">
    <Version>123.3.1.2</Version>
</PackageReference> 

</ItemGroup>
 

Here is the error, I'm facing>

Severity    Code    Description Project File    Line    Suppression State
Error   JAVA0000    Error in C:\\Users\\shobana.nagaraj.nuget\\packages\\xamarin.androidx.collection.jvm\\1.3.0.2\\buildTransitive\\net7.0-android33.0....\\jar\\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class:
Type androidx.collection.ArrayMapKt is defined multiple times: C:\\Users\\shobana.nagaraj.nuget\\packages\\xamarin.androidx.collection.jvm\\1.3.0.2\\buildTransitive\\net7.0-android33.0....\\jar\\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class, C:\\Users\\shobana.nagaraj.nuget\\packages\\xamarin.androidx.collection.ktx\\1.2.0.9\\buildTransitive\\net6.0-android31.0....\\jar\\androidx.collection.collection-ktx.jar:androidx/collection/ArrayMapKt.class
Compilation failed
java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\\Users\\shobana.nagaraj.nuget\\packages\\xamarin.androidx.collection.jvm\\1.3.0.2\\buildTransitive\\net7.0-android33.0....\\jar\\androidx.collection.collection-jvm.jar
androidx/collection/ArrayMapKt.class
at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:126)
at com.android.tools.r8.D8.main(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:5)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\\Users\\shobana.nagaraj.nuget\\packages\\xamarin.androidx.collection.jvm\\1.3.0.2\\buildTransitive\\net7.0-android33.0....\\jar\\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class
at Version.fakeStackEntry(Version_8.1.56.java:0)
at com.android.tools.r8.M.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:5)
at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:81)
at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:32)
at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:31)
at com.android.tools.r8.utils.R0.b(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:2)
at com.android.tools.r8.D8.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:26)
at com.android.tools.r8.D8.b(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:13)
at com.android.tools.r8.D8.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:24)
at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:113)
... 1 more
Caused by: com.android.tools.r8.utils.b: Type androidx.collection.ArrayMapKt is defined multiple times: C:\\Users\\shobana.nagaraj.nuget\\packages\\xamarin.androidx.collection.jvm\\1.3.0.2\\buildTransitive\\net7.0-android33.0....\\jar\\androidx.collection.collection-jvm.jar:androidx/collection/ArrayMapKt.class, C:\\Users\\shobana.nagaraj.nuget\\packages\\xamarin.androidx.collection.ktx\\1.2.0.9\\buildTransitive\\net6.0-android31.0....\\jar\\androidx.collection.collection-ktx.jar:androidx/collection/ArrayMapKt.class
at com.android.tools.r8.utils.O2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:21)
at com.android.tools.r8.utils.O2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:26)
at com.android.tools.r8.utils.A2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:44)
at com.android.tools.r8.utils.A2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:10)
at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2056)
at com.android.tools.r8.utils.A2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:6)
at com.android.tools.r8.graph.b4$a.e(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:7)
at com.android.tools.r8.dex.c.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:58)
at com.android.tools.r8.dex.c.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:9)
at com.android.tools.r8.dex.c.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:8)
at com.android.tools.r8.D8.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:29)
at com.android.tools.r8.D8.d(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:17)
at com.android.tools.r8.D8.c(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:1)
at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:28)
... 6 more
FirebaseMauiApp1        1

I refer more doc and discussions, they have suggested to add other packages of

"Xamarin.Build.Download" and<Package Reference Include="Xamarin.AndroidX.Fragment.Ktx" Version="1.6.2.2" />

But still I'm facing same issue. Also, I tried using downgraded version, it simply works for me, but I need to use the latest version without using any other packages to implement firebase push notifications.

I don't know, why it is causing error, even I didn't add "android collection . jvm" package. Please help me to get rid from this issue. I appreciate your support and thanks in advance.

1

There are 1 best solutions below

2
Cheesebaron On

Try adding the package:

<PackageReference Include="Xamarin.AndroidX.Collection.Jvm" Version="1.4.0.1" />

See more info here: https://github.com/xamarin/GooglePlayServicesComponents/issues/852 this issue occurs from time to time when packages are not fully in synch with the dependencies that they pull in implicitly.