Ich versuche, Google-Anmeldung zu verwenden. Ich habe diesen Code vor zwei Monaten geschrieben und es hat gut geklappt und als ich diese Woche wieder zum Code kam, wird er sich nicht verbinden. Ich habe in Googles Tutorial eingecheckt, aber es hat sich nichts geändert.Google-Anmeldung fehlgeschlagen
Die einzige Sache, die ich änderte, waren die Versionen in den gradle Akten, aber ich versuchte, sie wieder zu ändern und es half nicht.
Ich lese, dass "FAILED BINDER TRANSACTION" auftritt, wenn es ein großes Bild gibt, aber ich habe kein Bild hier.
Kann mir jemand sagen, was ich vermisse? Dies ist der Code:
GoogleApiClient mGoogleApiClient;
private static final int RC_SIGN_IN = 9001;
private ProgressDialog mProgressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
// Build a GoogleApiClient with access to the Google Sign-In API and the
// options specified by gso.
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Log.d("Login", "onConnectionFailed:" + connectionResult);
}
} /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
SignInButton signInButton = (SignInButton) findViewById(R.id.sign_in_button);
assert signInButton != null;
signInButton.setSize(SignInButton.SIZE_STANDARD);
signInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.sign_in_button:
signIn();
break;
}
}
});
}
private void handleSignInResult(GoogleSignInResult result) {
Log.d("Login Google", "handleSignInResult:" + result.isSuccess());
if (result.isSuccess()) {
// Signed in successfully, show authenticated UI.
GoogleSignInAccount acct = result.getSignInAccount();
Toast.makeText(this, "User name: " + acct.getDisplayName(), Toast.LENGTH_SHORT).show();
} else {
// Signed out, show unauthenticated UI.
Toast.makeText(this, "Sign Out", Toast.LENGTH_SHORT).show();
}
}
private void signIn() {
Log.v("Login", "SignIn");
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
}
}
Projektgrad:
dependencies {
classpath 'com.google.gms:google-services:3.0.0'
}
App gradle:
dependencies {
compile 'com.google.android.gms:play-services-auth:9.0.2' // Google Sign-in
compile 'com.google.android.gms:play-services:9.0.2'
apply plugin: 'com.google.gms.google-services' // Google Sign-in
}
Dies ist, was ich in der logcat erhalten:
07-26 10:41:53.275 V/Login: SignIn
07-26 10:41:53.433 E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 1442828)
07-26 10:41:53.764 D/Login Google: handleSignInResult:false
Danke, aber ich habe es versucht, es hat nicht geholfen. – MorZa