无法解析方法getAccount()

时间:2017-06-12 00:42:50

标签: java android google-api google-signin

因此,我一直按照指南here设置Google登录,这是所需的最后一段代码(稍加修改):

private void handleSignInResult(GoogleSignInResult result) {
    System.out.println("TAG - handleSignInResult:" + result.isSuccess());
    if (result.isSuccess()) {
        // Signed in successfully, show authenticated UI.
        GoogleSignInAccount acct = result.getSignInAccount();
        GoogleAccountCredential gac =
            GoogleAccountCredential.usingOAuth2(this,
            Collections.singleton(YOUTUBE_SCOPE));
        Account account = acct.getAccount(); // <--- Cannot resolve method getAccount()
    }
}

即使getAccount()GoogleSignInAccount的可用方法,也无法解析documented方法。

这里的问题是什么?

1 个答案:

答案 0 :(得分:0)

好的,想通了:

在应用级build.gradle文件中,我更改了

...

dependencies{
    ...
    compile 'com.google.android.gms:play-services-auth:9.0.0'
    ...
}

...

...

dependencies{
    ...
    compile 'com.google.android.gms:play-services-auth:10.2.6'
    ...
}

...

版本9.0.0不包含getAccount()方法。