官方谷歌加集成是否有错误?

时间:2016-05-20 07:22:36

标签: android google-plus-signin

我在这里按照教程: google-plus-integration

我已经尝试过一个简单的谷歌登录api没有问题。 阅读教程我写了这段代码:

mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */,
                  this /* OnConnectionFailedListener */)
.addApi(Plus.API)
.addScope(Scopes.PLUS_LOGIN)
.addScope(Scopes.PLUS_ME)
.build();

也许我很愚蠢但是这段代码在编译之前给了我一个错误:

  

生成器中的addScoper(com.google.android.gms.commin.api.Scope)无法应用于字符串

我尝试使用new Scope(Scopes.PLUS_LOGIN),但是当我运行该应用时,它会崩溃。 谷歌真的在他们的教程中提出了破碎的代码吗?

1 个答案:

答案 0 :(得分:0)

尝试使用Plus.SCOPE_PLUS_LOGIN(它返回Scope对象)

mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */,
                  this /* OnConnectionFailedListener */)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.addScope(Plus.SCOPE_PLUS_PROFILE)
.build();

请参阅:Plus | Google APIs for Android