我正在为我的项目使用Google Firebase身份验证的官方示例源代码。这个问题看似简单,但实际上并非如此。
我已声明对Gradle文件的依赖关系,如下所示:
// Firebase Authentication
implementation 'com.google.firebase:firebase-auth:16.0.3'
未按预期配置以下导入:
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthCredential;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.EmailAuthProvider;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
如果我将鼠标悬停在导入上,则说将库com.google.firebase:firebase-auth:16.0.3
添加到类路径。
app Gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
// compileSdkVersion 27
buildToolsVersion '28.0.2'
defaultConfig {
applicationId "com.sampletest.app.app"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
dependencies {
implementation project(':feature')
implementation project(':base')
// implementation 'com.android.support:appcompat-v7:27.1.1'
// implementation 'com.android.support:animated-vector-drawable:27.1.1'
// implementation 'com.android.support:cardview-v7:27.1.1'
// implementation 'com.android.support:design:27.1.1'
// Firebase Core
implementation 'com.google.firebase:firebase-core:16.0.3'
// Firebase Authentication
implementation 'com.google.firebase:firebase-auth:16.0.3'
// Ads
implementation 'com.google.firebase:firebase-ads:15.0.1'
// Analytics
implementation 'com.google.firebase:firebase-analytics:16.0.3'
// App Indexing
implementation 'com.google.firebase:firebase-appindexing:16.0.1'
// Cloud Firestore
implementation 'com.google.firebase:firebase-firestore:17.1.0'
// Cloud Functions
implementation 'com.google.firebase:firebase-functions:16.1.0'
// Cloud Messaging
implementation 'com.google.firebase:firebase-messaging:17.3.2'
// Cloud Storage
implementation 'com.google.firebase:firebase-storage:16.0.2'
// Crash Reporting
implementation 'com.google.firebase:firebase-crash:16.2.0'
// Crashlytics
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
// Dynamic Links
implementation 'com.google.firebase:firebase-dynamic-links:16.1.1'
// Invites
implementation 'com.google.firebase:firebase-invites:16.0.3'
// In-App Messaging
implementation 'com.google.firebase:firebase-inappmessaging:17.0.1'
// In-App Messaging Display
implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.1'
// ML Kit: Model Interpreter
implementation 'com.google.firebase:firebase-ml-model-interpreter:16.2.0'
// ML Kit: Vision
implementation 'com.google.firebase:firebase-ml-vision:17.0.0'
// ML Kit: Image Labeling
implementation 'com.google.firebase:firebase-ml-vision-image-label-model:15.0.0'
// Performance Monitoring
implementation 'com.google.firebase:firebase-perf:16.1.0'
// Realtime Database
implementation 'com.google.firebase:firebase-database:16.0.2'
// Remote Config
implementation 'com.google.firebase:firebase-config:16.0.0'
// Google Sign In SDK (only required for Google Sign In)
implementation 'com.google.android.gms:play-services-auth:16.0.0'
// Firebase UI
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
// Facebook Android SDK (only required for Facebook Login)
// Used in FacebookLoginActivity.
implementation 'com.facebook.android:facebook-login:4.35.0'
// implementation 'com.android.support:customtabs:27.1.1'
// Twitter Android SDK (only required for Twitter Login)
implementation 'com.twitter.sdk.android:twitter-core:3.3.0'
implementation 'com.twitter.sdk.android:twitter:3.3.0'
}
apply plugin: 'com.google.gms.google-services'
谢谢。
答案 0 :(得分:1)
尝试将实施版本从更改为
implementation 'com.google.firebase:firebase-auth:16.0.3'
到
implementation 'com.google.firebase:firebase-auth:16.0.4'
答案 1 :(得分:0)
在Android Studio中,转到工具-> Firebase->然后出现“助手”窗口,请遵循指南进行Firebase身份验证。
或从此处遵循准则:
答案 2 :(得分:0)
在您的项目gradle中添加
buildscript {
repositories {
google() // Google's Maven repository
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
在您的Build.Gradle (App Module)
项目应用程序gradle中
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-core:16.0.3'
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'