为什么我无法导入GoogleSignInClient类?

时间:2018-06-09 08:54:12

标签: java android api

我尝试使用谷歌无声登录,但GoogleSignInClient类由于某种原因未定义。当我进入alt-enter时,它只是说"创建课程"不是进口类。感谢任何帮助,谢谢!

enter image description here

private void signInSilently() {
    GoogleSignInClient signInClient = GoogleSignIn.getClient(this, GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
    signInClient.silentSignIn().addOnCompleteListener(this,
            new OnCompleteListener<GoogleSignInAccount>() {
                @Override
                public void onComplete(@NonNull Task<GoogleSignInAccount> task) {
                    if (task.isSuccessful()) {
                        // The signed in account is stored in the task's result.
                        GoogleSignInAccount signedInAccount = task.getResult();
                    } else {
                        // Player will need to sign-in explicitly using via UI
                    }
                }
            });
}

@Override
protected void onResume() {
    super.onResume();
    signInSilently();
}

此外:

implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-identity:15.0.1'

1 个答案:

答案 0 :(得分:0)

我通过更新文件

解决了这个问题
  

build.gradle(Project:projectname)

在此特定部分

从:

  

classpath&#39; com.google.gms:google-services:3.1.1&#39;

使用:

  

classpath&#39; com.google.gms:google-services:3.3.1&#39;