我正在尝试为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'MainActivity.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);
}我尝试过清理/重建项目和使缓存失效,但没有解决这个问题。我是不是漏掉了什么?
https://stackoverflow.com/questions/41275037
复制相似问题