xamarin / GooglePlayServicesComponents

Other
315 stars 148 forks source link

Error JAVA0000 when upgrading to 118.2.0.4 #825

Closed williambuchanan2 closed 2 months ago

williambuchanan2 commented 10 months ago

Xamarin.Android Version (eg: 6.0):

Operating System & Version (eg: Mac OSX 10.11):

Windows

Google Play Services Version

118.2.0.4

Describe your Issue

Get a build error:

Error JAVA0000 Error in C:\Ws_ng\xamarin.androidx.collection.jvm\1.3.0.1\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-jvm.jar:androidx/collection/ArraySetKt.class

Relevant information

Building .NET Maui app in Visual Studio. Worked ok in earlier version. Problem exists in .NET 7 and .NET 8.

Add relevant project settings from *.csproj file:

Packages used:

        <PackageReference Include="Xamarin.GooglePlayServices.Base" Version="118.2.0.4"/>
        <PackageReference Include="Xamarin.GooglePlayServices.Basement" Version="118.2.0.4"/>

        <PackageReference Include="Xamarin.AndroidX.Activity" Version="1.8.0.1" />
        <PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.8.0.1" />

Build settings (tools)

    <AndroidDexTool>d8</AndroidDexTool>
    <AndroidLinkTool>r8</AndroidLinkTool>
    <AndroidUseAapt2>true</AndroidUseAapt2>
    <AndroidEnableDesugar>true</AndroidEnableDesugar>

or even better - links to the existing code:

NOTE: Please DO NOT submit screenshot images. Images are not searchable!

Minimal Repro Code Sample

If you want to speed up investigation and bug fixing: please provide minimal repro sample for tests.

Steps to Reproduce (with link to sample solution if possible):

Include any relevant Exception Stack traces, build logs, adb logs:

hellcoderGIT commented 9 months ago

seeing the same error, 118.4.3 is the last working one, 118.4.3.1, 118.5.1 and 118.5.1.1 throw this error. (Maui - net8-android)

moljac commented 8 months ago

@williambuchanan2 @hellcoderGIT

Thanks for the feedback. Can you provide minimal repro sample please?

And lucky shot attempt:

try adding

<PackageReference Include="Xamarin.AndroidX.Collection.Jvm" Version="1.3.0.2" />
williambuchanan2 commented 8 months ago

try adding

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

@moljac

I added that but it didn't work. In fact it just caused another build problem.

Error JAVA0000 Error in C:\Ws_ng\xamarin.androidx.collection.ktx\1.2.0.9\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-ktx.jar:androidx/collection/ArrayMapKt.class: Type androidx.collection.ArrayMapKt is defined multiple times

hellcoderGIT commented 8 months ago

adding Xamarin.AndroidX.Collection(.Ktx) fixed it for me:

`

1.3.0.2
  <PackageReference Include="Xamarin.AndroidX.Collection.Ktx">
    <Version>1.3.0.2</Version>
  </PackageReference>
  <PackageReference Include="Xamarin.Firebase.Analytics">
    <Version>121.3.0.4</Version>
  </PackageReference>
  <PackageReference Include="Xamarin.Firebase.Crashlytics">
    <Version>118.5.1.1</Version>
  </PackageReference>
</ItemGroup>`
williambuchanan2 commented 8 months ago

Well done @hellcoderGIT !

It looks like nuget doesn't realise those dependencies are required. I had to add this in to my project and then manually update the version number in the csproj files because nuget was failing to do that as well.

        <PackageReference Include="Xamarin.AndroidX.Collection"><Version>1.3.0.2</Version></PackageReference>
        <PackageReference Include="Xamarin.AndroidX.Collection.Ktx"><Version>1.3.0.2</Version></PackageReference>
moljac commented 7 months ago

I added that but it didn't work.

Possibly. It transitive depends on ALL depenencies of ALL PackageReferences in your project. It gets worse with 3rd party packages (like plugins) which are not updated regularly.

The problem is that google moves types from artifact to artifact in different versions.

This issue will give you more insights into the problem

https://github.com/xamarin/AndroidX/issues/764

In fact it just caused another build problem.

Error JAVA0000 Error in C:\Ws_ng\xamarin.androidx.collection.ktx\1.2.0.9\buildTransitive\net6.0-android31.0....\jar\androidx.collection.collection-ktx.jar:androidx/collection/ArrayMapKt.class: Type androidx.collection.ArrayMapKt is defined multiple times

No. It is the same problem, but different nuget constellation.

moljac commented 7 months ago

Well done @hellcoderGIT !

maybe his app was a bit less complex and that simple trick worked.

It looks like nuget doesn't realise those dependencies are required.

Nuget does realise and if you check dependency tree you will see that those are referenced. It could be that there is 2+ versions of the same package.

I had to add this in to my project and then manually update the version number in the csproj files because nuget was failing to do that as well.

Again. Nuget does everything right. What you did is - you actually told nuget to forget all other packages and override them with versions you specified - (explicit reference).

        <PackageReference Include="Xamarin.AndroidX.Collection"><Version>1.3.0.2</Version></PackageReference>
        <PackageReference Include="Xamarin.AndroidX.Collection.Ktx"><Version>1.3.0.2</Version></PackageReference>

Did this addition help?

williambuchanan2 commented 7 months ago

Again. Nuget does everything right. What you did is - you actually told nuget to forget all other packages and override them with versions you specified - (explicit reference). Did this addition help?

Not sure I understand what you are saying. From my perspective Nuget should just work. I shouldn't need to manually edit files. In this case Nuget wasn't working. It wasn't including the dependencies. I didn't exclude anything - it just didn't work.

In fact the same problem occurred yesterday with the latest AndroidX packages. Same thing again - Nuget was failing to update them so I had to manually edit the csproj.

If you can see that I have done something to cause that let me know - but as I said I expect it to just work without me needing to do extra work.

moljac commented 2 months ago

Nuget works, but it works differently from Maven and you are using packages with Maven artifact bindings.

For the reason above- sometimes some manual work is necessary.

Closing this issue

williambuchanan2 commented 2 months ago

Nuget works, but it works differently from Maven and you are using packages with Maven artifact bindings.

For the reason above- sometimes some manual work is necessary.

Closing this issue

On Feb 14 you said Nuget does everything right. Today you are saying manual work is necessary. Which is it? If manual work is necessary then in my mind something isn't right. Clearly i'm not the only person having problems with this package.