I have a class in a library called with JNI throught networkHandler_GoogleSignin that will launch a fragment activity performing the the google sign in. The account selection is well displayed but after selecting the account I have this error 12501 : Status{statusCode=unknown status code: 12501, resolution=null} and a resultCode 0 in the onActivityResult of the fragment.
I searched the cause of this error, and only found that this error is linked with Oauth, so I tried with or without .requestIdToken(...) but got the same error.
I also tried to put the google-services.json in the root or app folder in the main project and the library project and again, same error (Anyway, my projects are on Eclipse and I understood that this json file is not needed on Eclipse).
So what could be the cause ?
Here is my code :
public class LibNetworkHandler extends FragmentActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener
{
static GoogleApiClient mGoogleApiClient;
static final int RC_SIGN_IN = 1;
public static native void requestCompletedCallback(String result);
private static Intent thisActivity;
private static Activity mainActivity;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
//.requestIdToken(web_client_id)
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(S3DXAndroidTools.getMainActivity().getApplicationContext())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
}
@Override
public void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
@Override
public void onStop() {
super.onStop();
mGoogleApiClient.disconnect();
}
public static void networkHandler_GoogleSignin (final String parameters)
{
setIncomingParameters(parameters);
mainActivity = S3DXAndroidTools.getMainActivity();
thisActivity = new Intent(S3DXAndroidTools.getMainActivity().getApplicationContext(),LibNetworkHandler.class);
mainActivity.startActivity(thisActivity);
Log.e("test", "test45 : " + thisActivity.toString());
}
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.e("test", "test35 : " + data.toString());
// Result returned from launching the Intent from
// GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {Log.e("test", "test3");
GoogleSignInAccount acct = result.getSignInAccount();
String output=setOutputParameters(acct.getId());
requestCompletedCallback(output);
}else{
Log.e("test", "test27 : "+result.getStatus().toString());
}
}
}
@Override
public void onConnectionFailed(ConnectionResult arg0) {
Log.e("error", "connexion failed ");
}
@Override
public void onConnected(Bundle arg0) {
if(mGoogleApiClient.isConnected()){
Log.e("test", "Google play connexion ok");
}
}
@Override
public void onConnectionSuspended(int arg0) {
// TODO Auto-generated method stub
}
}
EDIT
I found what the issue was : it seems that after migrating my project to firebase and adding both the library package and the main package under the same project that I needed to import the firebase plugin in my library build.gradle, even if I wasn't using the firebase sign in in my code. Also, the valid web id key changed after migrating the project on it and the .requestIdToken() method seems to be not optionnal with firebase