这是我尝试实例化的代码:
gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(PSSignInFlowActivity.this)
.enableAutoManage(this/* FragmentActivity */, new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
}
} /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
这就是我在build.gradle中的内容:
compile 'com.google.android.gms:play-services-maps:+'
compile 'com.google.android.gms:play-services-location:+'
compile 'com.google.android.gms:play-services-gcm:+'
compile 'com.google.android.gms:play-services-analytics:+'
compile 'com.google.android.gms:play-services-auth:9.0.2'
我收到此错误:
07-19 11:23:47.668: E/AndroidRuntime(2275): FATAL EXCEPTION: main
07-19 11:23:47.668: E/AndroidRuntime(2275): Process: nl.hgrams.passenger, PID: 2275
07-19 11:23:47.668: E/AndroidRuntime(2275): java.lang.NoSuchMethodError: No virtual method zztw()Ljava/util/Set; in class Lcom/google/android/gms/common/internal/zzg; or its super classes (declaration of 'com.google.android.gms.common.internal.zzg' appears in /data/app/nl.hgrams.passenger-1/base.apk)
07-19 11:23:47.668: E/AndroidRuntime(2275): at com.google.android.gms.auth.api.signin.internal.zzd.<init>(Unknown Source)
07-19 11:23:47.668: E/AndroidRuntime(2275): at com.google.android.gms.auth.api.Auth$4.zza(Unknown Source)
07-19 11:23:47.668: E/AndroidRuntime(2275): at com.google.android.gms.auth.api.Auth$4.zza(Unknown Source)
07-19 11:23:47.668: E/AndroidRuntime(2275): at com.google.android.gms.common.api.GoogleApiClient$Builder.zza(Unknown Source)
07-19 11:23:47.668: E/AndroidRuntime(2275): at com.google.android.gms.common.api.GoogleApiClient$Builder.zzaof(Unknown Source)
07-19 11:23:47.668: E/AndroidRuntime(2275): at com.google.android.gms.common.api.GoogleApiClient$Builder.build(Unknown Source)
07-19 11:23:47.668: E/AndroidRuntime(2275): at nl.hgrams.passenger.activities.PSSignInFlowActivity.onCreate(PSSignInFlowActivity.java:75)
07-19 11:23:47.668: E/AndroidRuntime(2275): at android.app.Activity.performCreate(Activity.java:6251)
07-19 11:23:47.668: E/AndroidRuntime(2275): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
07-19 11:23:47.668: E/AndroidRuntime(2275): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
07-19 11:23:47.668: E/AndroidRuntime(2275): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
07-19 11:23:47.668: E/AndroidRuntime(2275): at android.app.ActivityThread.-wrap11(ActivityThread.java)
07-19 11:23:47.668: E/AndroidRuntime(2275): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
07-19 11:23:47.668: E/AndroidRuntime(2275): at android.os.Handler.dispatchMessage(Handler.java:102)
07-19 11:23:47.668: E/AndroidRuntime(2275): at android.os.Looper.loop(Looper.java:148)
07-19 11:23:47.668: E/AndroidRuntime(2275): at android.app.ActivityThread.main(ActivityThread.java:5417)
07-19 11:23:47.668: E/AndroidRuntime(2275): at java.lang.reflect.Method.invoke(Native Method)
07-19 11:23:47.668: E/AndroidRuntime(2275): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
07-19 11:23:47.668: E/AndroidRuntime(2275): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
答案 0 :(得分:3)
查看类似的issue,
将'com.google.android.gms:play-services-auth:9.0.2'
更改为
'com.google.android.gms:play-services-auth:9.2.0'
会正常工作。
答案 1 :(得分:1)
添加了编译'com.google.android.gms:play-services-auth:+'而不是9.0.2