Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

App crash in Android 12 devices because of Xamarin.Auth #459

Open
1 task
suman-chava-by opened this issue Nov 19, 2021 · 16 comments
Open
1 task

App crash in Android 12 devices because of Xamarin.Auth #459

suman-chava-by opened this issue Nov 19, 2021 · 16 comments

Comments

@suman-chava-by
Copy link

suman-chava-by commented Nov 19, 2021

Xamarin.Auth Issue

Issue: In Android 12 (the recently released Android version), the mobile application crashes when the user tries to login via SSO. After debugging for the root cause, it is found that, Xamarin.Auth nuget is throwing an error as shown below :

"Java.Lang.IllegalArgumentException: {packageName}: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles."

Please find below the code at which the error is thrown :

var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
presenter.Login(authenticator);

Is there any Fix targeted or Currently being worked on by the MS Xamarin team to fix this?

Impact : More than 10K users will be impacted once they have upgraded their Android Devices OS to Android 12, since they can't login to their app because of this issue.

Version

  • nuget version = 1.7.0

Platform:

  • [] .NET version = NetStandard.Library (2.0.3)
  • Tools Used = VS 2019, Xamarin Forms, Xamarin Android

Expected behaviour

App should redirect the login flow to an SSO Webpage and display the login screeen.

Actual behaviour

App is crashing instead of redirecting to SSO web page

Screenshot :

MicrosoftTeams-image (8)

@akhil-shukla-by
Copy link

@xamarin-release-manager Kindly help us as this is a blocker for Android 12

@akhil-shukla-by
Copy link

The fix details:

Project: Xamarin.Auth.XamarinAndroid
File : CustomTabsConfiguration.cs
Line number : 470

Fix:

PendingIntent broadcast = PendingIntent.GetBroadcast
(
activity.ApplicationContext,
actionSourceId,
actionIntent,
//0 : this needs to be removed and immutable flag needs to be added.
PendingIntentFlags.Immutable
);

@akhil-shukla-by
Copy link

image

@yasmanillanes
Copy link

Is this project not being maintained anymore? Is this fix ever going to be released?

@kyluke
Copy link

kyluke commented May 10, 2022

When is this being fixed?

@frixos25
Copy link

I am waiting for this fix....

@nc-kano
Copy link

nc-kano commented Oct 27, 2022

it is not worth it to ask for fix. it will be never fixed as the last change in the repo was 3 years ago. In our project we had to fork the repo and build a custom version of it on our own. But the best solution is just to drop it and use something good instead.

@sviluppomania
Copy link

@moljac

@christian-strydom
Copy link

This is so frustrating. On StackOverflow it is suggested to install the Xamarin.AndroidX.Work.Runtime package to get around the issue, but it seems there are Kotlin version mismatches between the packages then. Has anyone been able to find a workaround for this?

@sviluppomania
Copy link

Questo è così frustrante. Su StackOverflow si consiglia di installare il pacchetto Xamarin.AndroidX.Work.Runtime per aggirare il problema, ma sembra che ci siano mancate corrispondenze di versione di Kotlin tra i pacchetti. Qualcuno è stato in grado di trovare una soluzione per questo?

@MattiaVicari

@christian-strydom
Copy link

This is so frustrating. On StackOverflow it is suggested to install the Xamarin.AndroidX.Work.Runtime package to get around the issue, but it seems there are Kotlin version mismatches between the packages then. Has anyone been able to find a workaround for this?

Turns out I had to update some of my other nuget packages. But unfortunately Xamarin.AndroidX.Work.Runtime package did not solve the issue. I ended up using Plugin.GoogleClient package with Firebase setup to get Google sign in on Android and iOS working.

@MattiaVicari
Copy link

If we want to continue using this package in our Xamarin project, I think the only thing we can do is fork the repository and fix the issue ourselves. I did too (here my fork), as someone else said.
It is very sad that no one is maintaining this repository....

I have built the DLLs, uninstalled the Xamarin.Auth package from my project and added them as reference:

  • the Xamarin.Auth\source\Core\Xamarin.Auth.Common.LinkSource\bin\Release\Xamarin.Auth.dll for common project
  • the Xamarin.Auth\source\Core\Xamarin.Auth.XamarinAndroid\bin\Release\Xamarin.Auth.dll for Android project
  • the Xamarin.Auth\source\Core\Xamarin.Auth.UniversalWindowsPlatform\bin\Release\Xamarin.Auth.dll for UWP project

@TheSundayDev
Copy link

ciao all,
so no official way to fix? thanks Mattia.
is there any other way to login using google in xamarin form?
thanks

@andygikling
Copy link

Run away from this repo, and Xamarin, as fast as you can. What a joke.

@jhonata0302
Copy link

jhonata0302 commented Jul 28, 2023

a possible solution is to use the Xamarin.Essentials library with Xamarin.Essentials.WebAuthentic
https://learn.microsoft.com/xamarin/essentials/web-authenticator?context=xamarin%2Fandroid&tabs=android

@Gvtha23
Copy link

Gvtha23 commented Oct 5, 2023

Is any solution for resolving this issue of Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent while calling the below code

var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
presenter.Login(authenticator);

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