Error detail :
Unhandled Exception:
System.NotSupportedException: Unable to activate instance of type PinCard.Mobile.Droid.Plugins.FacebookProvider_Android from native handle 0xfff3f75c (key_handle 0xce11d20). occurred
How to do resolve this issue ???
MainActivity.cs
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
FacebookSdk.ApplicationId = GetString(Resource.String.facebook_app_id);
FacebookSdk.SdkInitialize(ApplicationContext);
.......
}
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
if (FacebookProvider_Android.Current != null)
{
var result = false;
try
{
//Error Here
**result = FacebookProvider_Android.Current.CallbackManager.OnActivityResult(requestCode, (int)resultCode, data);**
if (result)
FacebookProvider_Android.Current.OnSuccess(result);
}
catch (Exception ex)
{
//Do SomeThing
}
}
if (GoogleProvider_Android.Current != null)
GoogleProvider_Android.Current.OnActivityResult(requestCode, (int)resultCode, data);
base.OnActivityResult(requestCode, resultCode, data);
InAppBillingImplementation.HandleActivityResult(requestCode, resultCode, data);
}
FacebookProvider_Android.cs
[assembly: Dependency(typeof(FacebookProvider_Android))]
namespace PinCard.Mobile.Droid.Plugins
{
public class FacebookProvider_Android : Java.Lang.Object, IFacebookCallback, IFacebookProvider
{
private TaskCompletionSource<string> _tcs;
public FacebookProvider_Android()
{
CallbackManager = CallbackManagerFactory.Create();
LoginManager.Instance.RegisterCallback(CallbackManager, this);
Current = this;
}
public static FacebookProvider_Android Current { get; private set; }
public ICallbackManager CallbackManager { get; set; }
public bool IsProcess { get; set; }
public void OnCancel()
{
_tcs.TrySetResult("");
}
public void OnError(FacebookException error)
{
_tcs.TrySetResult("");
}
public void OnSuccess(Java.Lang.Object result)
{
if (result is LoginResult lr)
{
AccessToken = lr.AccessToken.Token;
UserId = lr.AccessToken.UserId;
}
_tcs.TrySetResult(AccessToken);
}
public string UserId { get; private set; } // Implement from Interface
public string AccessToken { get; private set; } // Implement from Interface
public IntPtr Handle { get; set; } //=> throw new NotImplementedException();
public Task<string> LoginAsync() // Implement from Interface
{
try
{
string[] scopes = { "email", "public_profile", "user_friends" };
if (IsProcess)
return Task.FromResult("");
_tcs = new TaskCompletionSource<string>();
IsProcess = true;
LoginManager.Instance.LogInWithReadPermissions(
CrossCurrentActivity.Current.Activity, scopes);
return _tcs.Task;
}
catch (System.Exception)
{
//TODO: Log
}
finally
{
IsProcess = false;
}
return Task.FromResult("");
}
public void Dispose()
{
}
}
}
LoginPage.cs
private async Task SignInAsync(string provider)
{
IAuthenticationProvider authProvider;
switch (provider)
{
case "Facebook":
authProvider = DependencyService.Get<IFacebookProvider>();
break;
case "Google":
authProvider = DependencyService.Get<IGoogleProvider>();
break;
default:
authProvider = DependencyService.Get<IAuthenticationProvider>();
break;
}
}
Thanks All.