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

Issues with Upgrading Firebase Authentication Package and Xamarin.AndroidX.Browser in .NET MAUI #17935

Closed
Regis-Caelum opened this issue Oct 10, 2023 · 0 comments

Comments

@Regis-Caelum
Copy link

I've been trying to create an app using .NET MAUI where I'm implementing Firebase authentication for mobile phone number verification. I'm using .NET 7 SDK, and the package I'm using for Firebase authentication is Xamarin.Firebase.Auth version 121.0.8. This is because Firebase Admin SDK doesn't support mobile phone verification.

However, I'm encountering issues when trying to upgrade the package to the latest version. Whenever I attempt to upgrade the package, it results in the following conflict:

Error NU1605 : Warning As Error: Detected package downgrade: Xamarin.AndroidX.Browser from 1.5.0.2 to 1.4.0.3. Reference the package directly from the project to select a different version. 
 YabieFrontend -> Xamarin.Firebase.Auth 122.0.0.2 -> Xamarin.AndroidX.Browser (>= 1.5.0.2) 
 YabieFrontend -> Xamarin.AndroidX.Browser (>= 1.4.0.3)

I also attempted to manually upgrade Xamarin.AndroidX.Browser, but this led to the following runtime exception:

Error JAVA0000 java: Error in /Users/inshalkhan/.nuget/packages/xamarin.androidx.lifecycle.common/2.6.2.1/buildTransitive/net6.0-android31.0/../../jar/androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/DispatchQueue.class:
Type androidx.lifecycle.DispatchQueue is defined multiple times: /Users/inshalkhan/.nuget/packages/xamarin.androidx.lifecycle.common/2.6.2.1/buildTransitive/net6.0-android31.0/../../jar/androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/DispatchQueue.class, obj/Debug/net7.0-android/lp/152/jl/classes.jar:androidx/lifecycle/DispatchQueue.class
Compilation failed
java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: /Users/inshalkhan/.nuget/packages/xamarin.androidx.lifecycle.common/2.6.2.1/buildTransitive/net6.0-android31.0/../../jar/androidx.lifecycle.lifecycle-common.jar
androidx/lifecycle/DispatchQueue.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: /Users/inshalkhan/.nuget/packages/xamarin.androidx.lifecycle.common/2.6.2.1/buildTransitive/net6.0-android31.0/../../jar/androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/DispatchQueue.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.lifecycle.DispatchQueue is defined multiple times: /Users/inshalkhan/.nuget/packages/xamarin.androidx.lifecycle.common/2.6.2.1/buildTransitive/net6.0-android31.0/../../jar/androidx.lifecycle.lifecycle-common.jar:androidx/lifecycle/DispatchQueue.class, obj/Debug/net7.0-android/lp/152/jl/classes.jar:androidx/lifecycle/DispatchQueue.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
Directory 'obj/Debug/net7.0-android/lp/152' is from 'androidx.lifecycle.lifecycle-runtime-ktx.aar'.

I've tried various solutions found on Stack Overflow, such as cleaning and rebuilding the project, but nothing seems to be resolving the issue. When I revert to the older version I'm currently using, I encounter a runtime exception related to the setPhoneNumber method.

System.InvalidCastException: Specified cast is not valid.
   at YabieFrontend.Services.AuthenticationService.AuthenticatePhoneNumber(String phoneNumber) in /Users/inshalkhan/RiderProjects/YabieFrontend/Platforms/Android/Services/AuthenticationService.cs:line 19
   at YabieFrontend.ViewModel.LoginViewModel.Login() in /Users/inshalkhan/RiderProjects/YabieFrontend/ViewModel/LoginViewModel.cs:line 26
   at CommunityToolkit.Mvvm.Input.AsyncRelayCommand.AwaitAndThrowIfFailed(Task executionTask) in /_/src/CommunityToolkit.Mvvm/Input/AsyncRelayCommand.cs:line 351
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at Android.App.SyncContext.<>c__DisplayClass2_0.<Post>b__0() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:line 36
   at Java.Lang.Thread.RunnableImplementor.Run() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:line 36
   at Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net7.0/android-33/mcw/Java.Lang.IRunnable.cs:line 84
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V callback, IntPtr jnienv, IntPtr klazz) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 22

Here's my code for reference:

public Task<bool> AuthenticatePhoneNumber(string phoneNumber)
    {
        _verificationCompletionSource = new TaskCompletionSource<bool>();

        
            var authOption = PhoneAuthOptions
                .NewBuilder()
                .SetPhoneNumber(phoneNumber)
                .SetTimeout((Long)60, TimeUnit.Seconds)
                .SetActivity(Platform.CurrentActivity)
                .SetCallbacks(this)
                .Build();

            PhoneAuthProvider.VerifyPhoneNumber(authOption);
        

        return _verificationCompletionSource.Task;
    }

Any assistance with resolving these issues would be greatly appreciated.

Originally posted by @Regis-Caelum in #14598 (reply in thread)

@ghost ghost locked as resolved and limited conversation to collaborators Nov 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant