当我向我的班级初始化Fire base身份验证时,应用程序停止 也许在问题中有问题,但每件事物都有一个托盘
这是我的代码
class Test : AppCompatActivity() {
lateinit var mAuth: FirebaseAuth
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_test)
mAuth = FirebaseAuth.getInstance()
}
}
这是我的礼物
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-config:16.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.0'
}
答案 0 :(得分:0)
您正在使用旧版本的Firebase依赖项,并且缺少Google服务插件。要解决此问题,请使用以下依赖项:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-config:16.1.3'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
还请添加以下强制性的依赖项:
implementation 'com.google.firebase:firebase-core:16.0.6'
您的应用gradle文件现在必须明确列出
com.google.firebase:firebase-core
作为Firebase服务按预期工作的依赖项。
在顶级build.gradle
文件中,请确保具有最新版本的Google服务插件:
classpath 'com.google.gms:google-services:4.2.0'