I need your help ... I have no idea!
I donβt understand why he fails every time.
- I created OAuth 2.0 client identifiers.
- I generated and moved the
google-services.json folder to ./app . - The Google Cloud Console supports all Google APIs where they are activated.
Check out and if something hurts you ... Go on!
Yours faithfully
build.gradle:
apply plugin: 'com.google.gms.google-services' android { compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "sign.in.gogoleplusconnect" minSdkVersion 16 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.0.0' compile 'com.google.android.gms:play-services-auth:9.0.0' compile 'com.google.android.gms:play-services-identity:9.0.0' compile 'com.google.android.gms:play-services:9.0.0' }
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_marginTop="5dp" android:layout_centerHorizontal="true" android:text="Gogole Sign In" android:textSize="30sp" android:textColor="#000000"/> <com.google.android.gms.common.SignInButton android:id="@+id/sign_in_button" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/title" android:layout_margin="20dp" android:layout_marginTop="20dp"/> </RelativeLayout>
MainActivity.java
package sign.in.gogoleplusconnect; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import com.google.android.gms.auth.api.Auth; import com.google.android.gms.auth.api.signin.GoogleSignInAccount; import com.google.android.gms.auth.api.signin.GoogleSignInOptions; import com.google.android.gms.auth.api.signin.GoogleSignInResult; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.SignInButton; import com.google.android.gms.common.api.GoogleApiClient; public class MainActivity extends AppCompatActivity implements GoogleApiClient.OnConnectionFailedListener, View.OnClickListener { private static final int RC_SIGN_IN = 9001; private GoogleSignInOptions gso; private GoogleApiClient mGoogleApiClient; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Log.d("Logger", "onCreate:");
Logcat.log
07-15 16:06:27.817 21424-21424/sign.in.gogoleplusconnect D/Logger: onCreate: 07-15 16:06:30.053 21424-21424/sign.in.gogoleplusconnect D/Logger: onClick: 07-15 16:06:30.055 21424-21424/sign.in.gogoleplusconnect D/Logger: signIn: 07-15 16:06:32.872 21424-21424/sign.in.gogoleplusconnect D/Logger: onActivityResult:RC_SIGN_IN : 9001 07-15 16:06:32.879 21424-21424/sign.in.gogoleplusconnect D/Logger: handleSignInResult:false 07-15 16:06:32.879 21424-21424/sign.in.gogoleplusconnect D/Logger: handleSignInResult : Fail
source share