因此,我一直按照指南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方法。
这里的问题是什么?
答案 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()
方法。