gpt4 book ai didi

android - 找不到符号类 GoogleSignInApi

转载 作者:太空狗 更新时间:2023-10-29 16:30:17 32 4
gpt4 key购买 nike

我正在尝试使用 Google for Firebase 设置身份验证并遵循此 document .

但是我遇到了这些错误:

error: cannot find symbol class GoogleSignInApi
error: cannot find symbol variable RC_SIGN_IN

我的build.gradle(应用程序)

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.myapp.sc"
minSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.firebaseui:firebase-ui:1.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.android.gms:play-services-auth:10.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

主 Activity .java

private FirebaseAuth mAuth;
private AuthStateListener mAuthListener;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// setup google sign in
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.clientId)).requestEmail().build();
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, (OnConnectionFailedListener) this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();

if (mAuth.getCurrentUser() == null) {
signIn(mGoogleApiClient);
}
}

private void signIn(GoogleApiClient mGoogleApiClient) {
Intent signInIntent = new Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
}

我已经尝试清理/重建项目并使缓存失效,但它并没有解决问题。有什么我想念的吗?

最佳答案

添加这一行:

Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);

取而代之的是:

Intent signInIntent = new Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);

并添加:

private static int RC_SIGN_IN = 100;

还需要:

import com.google.android.gms.auth.api.Auth;

关于android - 找不到符号类 GoogleSignInApi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41275037/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com