1

I have added Google sign in as given in link

and Integrated using Start Integrating Google Sign-In into Your Android App

In login activity OnCreate method init it as illustrated in above link.

// [START configure_signin]
// Configure sign-in to request the user's ID, email address, and basic
// profile. ID and basic profile are included in DEFAULT_SIGN_IN.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
        .requestIdToken(getResources().getString(R.string.google_server_client_id))
        .requestEmail()
        .build();

// [END configure_signin]

// [START build_client]
// 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 */, this /* OnConnectionFailedListener */)
        .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
        .build();

// [END build_client]

When I force stop the app and open again it gives NPE as

Crash Report Thread:main Exception:java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Context.bindService(android.content.Intent, android.content.ServiceConnection, int)' on a null object reference
at com.google.android.gms.common.stats.zza.zza(Unknown Source)
at com.google.android.gms.common.internal.zzo$zzb.zzdr(Unknown Source)
at com.google.android.gms.common.internal.zzo.zza(Unknown Source)
at com.google.android.gms.common.internal.zzo.zza(Unknown Source)
at com.google.android.gms.common.internal.zzf.zzwR(Unknown Source)
at com.google.android.gms.common.internal.zzf.zza(Unknown Source)
at com.google.android.gms.common.internal.zzf.zza(Unknown Source)
at com.google.android.gms.internal.zzaaj$zzb.zzvA(Unknown Source)
at com.google.android.gms.internal.zzaaj$zzf.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at com.google.android.gms.internal.zzacv.run(Unknown Source)
at java.lang.Thread.run(Thread.java:818)

Similar unanswered question : Rare NullPointerException in GoogleApiClient using Firebase

Community
  • 1
  • 1
Giru Bhai
  • 14,370
  • 5
  • 46
  • 74
  • You may want to check [Authenticate with Firebase](https://firebase.google.com/docs/auth/android/google-signin#authenticate_with_firebase) and see if you've missed something. – Teyam May 10 '17 at 11:08
  • @Teyam Did same, till Google Sign In only, because I don't want to authenticate with Firebase. – Giru Bhai May 10 '17 at 11:18
  • Try using [`void onServiceConnected (ComponentName name, IBinder service)`](https://developer.android.com/reference/android/content/ServiceConnection.html#onServiceConnected(android.content.ComponentName,android.os.IBinder)) which will be called when the connection to the Service has been established. See this [SO post](http://stackoverflow.com/a/35088205) for additional insights. – Teyam May 10 '17 at 11:33
  • @Teyam as given in this link https://developers.google.com/identity/sign-in/android/start-integrating, connection will be auto managed and I also used it as `enableAutoManage` – Giru Bhai May 10 '17 at 12:08
  • This could be another manifestation of the [bug](https://github.com/firebase/quickstart-android/issues/291), also reported [here](https://stackoverflow.com/questions/42362024/firebase-remote-config-nullpointerexception-on-map-keyset) – Alex Cohn Jan 14 '18 at 11:50

0 Answers0