GoogleSignInOptions, GoogleApiClient bind service ServiceConnection Crash

﹥>﹥吖頭↗ 提交于 2019-12-24 09:39:51

问题


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

来源:https://stackoverflow.com/questions/43864774/googlesigninoptions-googleapiclient-bind-service-serviceconnection-crash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!