GooglePlayServicesComponents icon indicating copy to clipboard operation
GooglePlayServicesComponents copied to clipboard

Error JAVA0000 when upgrading to 118.2.0.4

Open williambuchanan2 opened this issue 1 year ago • 8 comments

Xamarin.Android Version (eg: 6.0):

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

Windows

Google Play Services Version

118.2.0.4

  • [] GPS-FB with AndroidX dependencies (versions 1xx.yyyy.zz)

  • [] GPS-FB with Android.Support (legacy) dependencies (versions 71.yyyy.zz)

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:

  • https://github.com/xamarin/AndroidX/blob/master/samples/BuildAll/BuildAll/BuildAll.csproj#L41-L44

  • https://github.com/xamarin/AndroidX/blob/master/samples/BuildXamarinFormsApp/BuildXamarinFormsApp/BuildXamarinFormsApp.Android/BuildXamarinFormsApp.Android.csproj#L57-L58

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:

williambuchanan2 avatar Dec 06 '23 08:12 williambuchanan2

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)

hellcoderGIT avatar Dec 13 '23 09:12 hellcoderGIT

@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" />

moljac avatar Jan 15 '24 13:01 moljac

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

williambuchanan2 avatar Jan 18 '24 02:01 williambuchanan2

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

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'"> <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> <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>

hellcoderGIT avatar Jan 18 '24 05:01 hellcoderGIT

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>

williambuchanan2 avatar Jan 19 '24 03:01 williambuchanan2

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 avatar Feb 14 '24 08:02 moljac

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?

moljac avatar Feb 14 '24 09:02 moljac

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.

williambuchanan2 avatar Feb 14 '24 21:02 williambuchanan2

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

moljac avatar Jul 19 '24 12:07 moljac

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.

williambuchanan2 avatar Jul 21 '24 22:07 williambuchanan2