Im having a problem using WebAuthenticator on Xamarin.Android
Everytime i try to log in via a external service (Goverment From Brazil) it returns me Java.Lang.RuntimeException: 'Unable to instantiate activity ComponentInfo
Heres the class that implements the WebAuthenticatorCallbackActivity:
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TesouroDiretoMobile.Configuration.Droid
{
[Activity(NoHistory = true, LaunchMode = LaunchMode.SingleTop, Exported = true, Name = "br.gov.fazenda.tesouro.td.CallBackActivity", Label = "TesouroDireto")]
[IntentFilter(new[] { Android.Content.Intent.ActionView },
Categories = new[] { Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable },
DataScheme = "tesourodireto://retornologinunico")]
public class AutenticadorGovBr : Xamarin.Essentials.WebAuthenticatorCallbackActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
}
}
}
My android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="br.gov.fazenda.tesouro.td" android:versionName="2.3.13" android:versionCode="10826">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="false" android:xlargeScreens="false" android:largestWidthLimitDp="840" />
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<application android:label="Tesouro Direto" android:theme="@style/MyTheme" android:icon="@drawable/icon" android:largeHeap="true" android:allowBackup="true">
<!-- largeHeap utilizado devido a problemas encontrados no uso do plugin fingerprint -->
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/icon" />
<meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/primary" />
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
<activity android:name="br.gov.fazenda.tesouro.td.CallBackActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tesourodireto" android:host="retornologinunico" />
</intent-filter>
</activity>
</application>
</manifest>
The call for the authenticator
var uriBuilder = new StringBuilder(AppSettings.SegurancaBaseAddress);
uriBuilder.Append("/authorize");
uriBuilder.Append($"?response_type={AppSettings.ResponseType}");
uriBuilder.Append($"&client_id={Criptografia.Descriptografar(AppSettings.ClientId)}");
uriBuilder.Append($"&scope={AppSettings.Scope}");
uriBuilder.Append($"&redirect_uri={HttpUtility.UrlEncode(AppSettings.RedirectUri,Encoding.UTF8)}");
uriBuilder.Append($"&nonce={Guid.NewGuid()}");
uriBuilder.Append($"&state={Guid.NewGuid()}");
var authResult = await Xamarin.Essentials.WebAuthenticator.AuthenticateAsync(
new Uri(uriBuilder.ToString()),
new Uri(AppSettings.RedirectUri));
var accessToken = authResult?.Properties["code"];
await IniciarSessaoGovBr(accessToken, string.Empty);
It only happens in android, IOS it works fine
I already tryed updating the packages, changing the name, recreating it all on other branch, and the error keeps ocurring