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

Maui.essentials 7.096 incompatible with Android GooglePlayServices Nugets like recaptcha #18118

Closed
rfrailemartinez opened this issue Oct 18, 2023 · 14 comments
Assignees
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info platform/android 🤖 s/needs-info Issue needs more info from the author s/needs-verification Indicates that this issue needs initial verification before further triage will happen s/triaged Issue has been reviewed t/bug Something isn't working
Milestone

Comments

@rfrailemartinez
Copy link

rfrailemartinez commented Oct 18, 2023

Description

if you have a net 7 project with
true
And add for example nuget Xamarin.Google.Android.Recaptcha, that has referente to Xamarin.GooglePlayServices.---
if you try to build app you get next error:

/Users/rfraile/proyectos/SELAE/Workspace/SELAE.Droid: Error JAVA0000: Error in obj/Debug/net7.0-android33.0/lp/135/jl/classes.jar:androidx/activity/OnBackPressedDispatcherKt.class:
Type androidx.activity.OnBackPressedDispatcherKt is defined multiple times: obj/Debug/net7.0-android33.0/lp/135/jl/classes.jar:androidx/activity/OnBackPressedDispatcherKt.class, obj/Debug/net7.0-android33.0/lp/103/jl/classes.jar:androidx/activity/OnBackPressedDispatcherKt.class
Compilation failed
java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj/Debug/net7.0-android33.0/lp/135/jl/classes.jar
androidx/activity/OnBackPressedDispatcherKt.class
	at com.android.tools.r8.internal.Fj.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:98)
	at com.android.tools.r8.D8.main(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:4)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj/Debug/net7.0-android33.0/lp/135/jl/classes.jar:androidx/activity/OnBackPressedDispatcherKt.class
	at Version.fakeStackEntry(Version_3.3.75.java:0)
	at com.android.tools.r8.internal.Fj.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:75)
	at com.android.tools.r8.internal.Fj.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:28)
	at com.android.tools.r8.internal.Fj.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:27)
	at com.android.tools.r8.internal.Fj.b(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:2)
	at com.android.tools.r8.D8.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:22)
	at com.android.tools.r8.D8.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:17)
	at com.android.tools.r8.internal.Fj.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:85)
	... 1 more
Caused by: com.android.tools.r8.internal.f: Type androidx.activity.OnBackPressedDispatcherKt is defined multiple times: obj/Debug/net7.0-android33.0/lp/135/jl/classes.jar:androidx/activity/OnBackPressedDispatcherKt.class, obj/Debug/net7.0-android33.0/lp/103/jl/classes.jar:androidx/activity/OnBackPressedDispatcherKt.class
	at com.android.tools.r8.internal.JT.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:14)
	at com.android.tools.r8.internal.JT.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:22)
	at com.android.tools.r8.internal.HN.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:33)
	at com.android.tools.r8.internal.HN.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:10)
	at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2048)
	at com.android.tools.r8.internal.HN.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:6)
	at com.android.tools.r8.graph.B2$a.e(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:4)
	at com.android.tools.r8.dex.b.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:110)
	at com.android.tools.r8.dex.b.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:28)
	at com.android.tools.r8.D8.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:25)
	at com.android.tools.r8.D8.d(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:606)
	at com.android.tools.r8.D8.c(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:1)
	at com.android.tools.r8.internal.Fj.a(R8_3.3.75_b7a6ff6b13548611571508fe72282c9167faa649161ca0013edfc92e19bd7e58:24)
	... 5 more
El directorio "obj/Debug/net7.0-android33.0/lp/135" es de "androidx.activity.activity-ktx.aar". (JAVA0000) (SELAE.Droid) java

I think is important that you can specify the maui essentials versions that you want to use, like we did before net7 with Xamarin essentials nuget. is there a way to do that?

Thank you

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

7.0.96

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

@rfrailemartinez rfrailemartinez added the t/bug Something isn't working label Oct 18, 2023
@jsuarezruiz jsuarezruiz added platform/android 🤖 area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info labels Oct 19, 2023
@AnnYang01
Copy link

Verified this on Visual Studio Enterprise 17.8.0 Preview 4.0 using below Project (.NET 7.0), error JAVA0000 will occur, but it does not repro on .NET 8.0 project.
MauiApp1.zip
.NET 7.0
image
.NET 8.0
image

@AnnYang01 AnnYang01 added s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version labels Oct 19, 2023
@ghost
Copy link

ghost commented Oct 19, 2023

Hi @rfrailemartinez. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@rfrailemartinez
Copy link
Author

rfrailemartinez commented Oct 19, 2023

Hi @AnnYang01,
it is a great notice that it is fixed in net8 preview. This could be a solution for the fisrt part of the problem.

But the main problem is that I work in a big company with a lot of projects, part of this project are updated and part of them not, for example if I publish an app today, maybe this client doesn´t ask for fix or change in 6 or 10 months, maybe this client only wants a change over their tablets version, besause the app is not in google play.

The new way to insert Essentials in projects makes you to be up to day with all the nugets that could be in conflict, including manual bindings that are made in specifiq android and androidx versions. I think we should have the option to put the version of essentials we waant to do, something like:
<UseMauiEssentials version="7.0.96">true</UseMauiEssentials>
when we used Xamarin.essentials nugets, you could select older version. Maybe there is a way but I don´t know how.

I think this problem is not only for Essentials, it is also a problem with true, where you open a project that you did one year ago that compiles and works, and a new Maui version relased during this time could break something.

thank you for your support

@ghost ghost removed the s/try-latest-version Please try to reproduce the potential issue on the latest public version label Oct 19, 2023
@mattleibow
Copy link
Member

@moljac thoughts?

@mattleibow mattleibow added this to the Backlog milestone Oct 19, 2023
@ghost
Copy link

ghost commented Oct 19, 2023

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@moljac
Copy link
Contributor

moljac commented Oct 20, 2023

@moljac thoughts?

Type X is defined multiple times:

Known issue:

dotnet/android-libraries#764

The problem is

  1. we cannot keep pace with google, so bindings are not 1:1
  2. nuget and maven SemVer rules (min, max, range, pinning/exact) differ
    we did some PRs to solve that, but not tested extensively yet
  3. google moving types around from artifact to artifact from version to version
  4. complexity of real-world projects (AX, GPS-FB-MLKit packages then plugins) and transitive dependencies
    Most issues are from real world apps and solution is to investigate dependency forest for PackageReferences.
    If the offending package is found adding explicit PackageReference with latest version does solve the problem in
    most cases.

In this case GPS-FB-MLKit repo was not updated for 3 moonths, because CI buids fail because of Cake.Tool. I fixed Cake.Tool but version 3.2.0 was not released yet.
I do use locally preview and I did create PR so we could use it in AX and GPS-FB-MLKit repos.

dotnet/android-libraries#802

So, in this case (quick-n-dirty analysis) I would explicitly add Xamarin.AndroidX.Activity.* 1.8.0.1 packages.
If that does not help I must investigate dependencies.

2nd option would be to wait for updates and I hope I will be able to release soon.

@moljac
Copy link
Contributor

moljac commented Oct 22, 2023

1st round of updates was merged, tagged, but publishing fails, because required ComponentDetection (Components Governance step) step fails because aar files are not recognized.

Shortly after that there will be more updates

xamarin/GooglePlayServicesComponents#803

@moljac
Copy link
Contributor

moljac commented Oct 23, 2023

From community feedback:

Try adding following references:

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

Related:

dotnet/android-libraries#800 (comment)

@moljac
Copy link
Contributor

moljac commented Oct 30, 2023

@rfrailemartinez

Did you try this workaround??

Try adding following references:

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

.NET Android team released 2 rounds of GPS-FB-MLKit nugets. Can you please update your dependencies to latest and see?
And please provide feedback here. Thanks.

@moljac moljac self-assigned this Oct 31, 2023
@moljac moljac added s/needs-info Issue needs more info from the author s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Oct 31, 2023
@ghost
Copy link

ghost commented Oct 31, 2023

Hi @rfrailemartinez. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@moljac
Copy link
Contributor

moljac commented Nov 1, 2023

Closing this issue. If the proposed solution does not work - open new issue please

@moljac moljac closed this as completed Nov 1, 2023
@rfrailemartinez
Copy link
Author

Hi @moljac,

Excuse me for the delay, we remove essentials from our project.
I have tested now and it's not necessary to add
<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.3.0.1" /> <PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.3.0.1" />
I think maybe verion 7.0.100 fix the problem that we had with 7.0.96

It is a pity, but we decide that we are not going to use essentials in any net project until we have something similar to nuget version selection.
We have a lot of clients, some of them banks or similar, and we must have a way to specify the version of the libraries we use, like we said before, for example something like
<UseMauiEssentials Version="7.0.96">true</UseMauiEssentials>
We can not block a pass to production because for example a new verion of essentials appears one day before, the app doesn´t compile and we have to look for what package is in collision and have to be updated.

Thank you very much for your support and if version selection is develop, please advise us.
We can test anything else more, that you think it can help you improve this.
We love xamarin (Net mobile), and we have a lot of projects: Native, Forms, and starting projects with Maui and Net mobile.

@dodikk
Copy link

dodikk commented Nov 6, 2023

@AnnYang01 I have tried to build the project you've attached in a zip file on MacOS with "Visual Studio for mac" build 17.6.6 (build 408). And it fails both with net7 and net8 <TargetFrameworks> in the .csproj file.
Any ideas?

@AnnYang01
Copy link

AnnYang01 commented Nov 7, 2023

Hi @dodikk, you can open a new ticket and provide more details of the failed error and attach a simple project.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info platform/android 🤖 s/needs-info Issue needs more info from the author s/needs-verification Indicates that this issue needs initial verification before further triage will happen s/triaged Issue has been reviewed t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants