If I checked Sign the .APK ..... in Project's Properties => Error MSB6006: "java.exe" exited with code 2 . if not checked , result.IsSuccess always is null .
Information Keystore file if i checked :
{
Keystore : Keystores\PinCard.keystore
Keystore Password : 1234567
Alias : PinCard
Alias Password : 1234567
}
Have :
String.xml
<?xml version="1.0" encoding="utf-8" ?>
XXX
65664729479598X
fb65664729479598X
651123525463-8oe68aqqqj99hd2pue0ish8jn79pf2oo.apps.googleusercontent.com
GoogleProvider_Android.cs
[assembly: Dependency(typeof(GoogleProvider_Android))]
namespace PinCard.Mobile.Droid.Plugins
{
public class GoogleProvider_Android : Java.Lang.Object, GoogleApiClient.IOnConnectionFailedListener, IGoogleProvider
{
private const int RC_SIGN_IN = 9001;
private const string WEB_CLIENT_ID = "651123525463-ku757eclved5fr5rv3v9p9rdc7k12oro.apps.googleusercontent.com";
public static GoogleProvider_Android Current { get; private set; }
private TaskCompletionSource _tcs;
public GoogleProvider_Android()
{
Current = this;
}
public GoogleApiClient ApiClient { get; private set; }
public bool Resolving { get; private set; }
public bool ShouldResolve { get; private set; }
public void SignOut()
{
if (ApiClient.IsConnected)
{
Auth.GoogleSignInApi.SignOut(ApiClient);
ApiClient.Disconnect();
}
}
public void OnActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == RC_SIGN_IN)
{
ShouldResolve = resultCode != 1;
Resolving = false;
var result = Auth.GoogleSignInApi.GetSignInResultFromIntent(data);
HandleSignInResult(result);
}
}
private void HandleSignInResult(GoogleSignInResult result)
{
if (result.IsSuccess)
{
// Signed in successfully, show authenticated UI.
var acct = result.SignInAccount;
UserId = acct.Id;
AccessToken = result.SignInAccount.IdToken;
_tcs?.TrySetResult(true);
}
else
{
_tcs?.TrySetResult(false);
}
}
public string UserId { get; private set; }
public string AccessToken { get; private set; }
public IntPtr Handle { get; set; }//=> throw new NotImplementedException();
public Task<bool> LoginAsync()
{
_tcs = new TaskCompletionSource<bool>();
ShouldResolve = true;
var context = (AppCompatActivity)CrossCurrentActivity.Current.Activity;
if (ApiClient == null)
{
var gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn)
.RequestIdToken(WEB_CLIENT_ID)
.RequestEmail()
.Build();
ApiClient = new GoogleApiClient.Builder(context)
.EnableAutoManage(context, this)
.AddApi(Auth.GOOGLE_SIGN_IN_API, gso)
.Build();
}
var signInIntent = Auth.GoogleSignInApi.GetSignInIntent(ApiClient);
context.StartActivityForResult(signInIntent, RC_SIGN_IN);
return _tcs.Task;
}
public void OnConnectionFailed(ConnectionResult connectionResult)
{
if (!Resolving && ShouldResolve)
if (connectionResult.HasResolution)
try
{
connectionResult.StartResolutionForResult(CrossCurrentActivity.Current.Activity, RC_SIGN_IN);
Resolving = true;
}
catch (IntentSender.SendIntentException)
{
Resolving = false;
ApiClient.Connect();
}
else
_tcs.SetException(new Exception("No Resolution with: " + connectionResult.ErrorMessage));
}
public void Dispose()
{
}
}
MainActivity.cs
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
if (FacebookProvider_Android.Current != null)
FacebookProvider_Android.Current.CallbackManager.OnActivityResult(requestCode, (int)resultCode, data);
if (GoogleProvider_Android.Current != null)
GoogleProvider_Android.Current.OnActivityResult(requestCode, (int)resultCode, data);
base.OnActivityResult(requestCode, resultCode, data);
InAppBillingImplementation.HandleActivityResult(requestCode, resultCode, data);
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.whatzhat.PinCard" android:installLocation="auto"
android:versionName="0.4" android:versionCode="16">
<uses-sdk android:minSdkVersion="22" android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:label="PinCard" android:usesCleartextTraffic="true" android:largeHeap="true" android:icon="@mipmap/ic_launcher">
<meta-data android:name="com.google.gms.vision.DEPENDENCIES" android:value="ocr" />
<provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.fileprovider"
android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
</provider>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />
<activity android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/app_name" />
<activity android:name="com.facebook.CustomTabActivity" android:exported="true">
<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="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
</application>
</manifest>
.