android - 当我为我的班级初始化 Fire 基础身份验证时,应用程序停止
问题描述
当我为我的班级初始化 Fire 基础身份验证时,应用程序停止
可能会在 gradle 中出现问题,但每件事都有一个托盘
这是我的代码
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'
}
解决方案
您正在使用旧版本的 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'
推荐阅读
- angular - 如何将 mock.ts 文件中的数据绑定到组件?
- html - 在 Angular Material 中输入第一次不工作
- mysql - 每当 id 更改时,如何将用户定义的变量值设置为零?
- javafx - 填充组合框 FXML
- php - 所有页面都显示 404 Not Found Nginx 但主页工作正常
- swift - 在 Swift 中导入钠的问题
- c - 在 Linux 内核中使用 workqueue 或 kthread 执行 ELF
- php - 我有一个登录 php 文件给我这个错误“mysqli_stmt_close() 期望参数 1 是 mysqli_stmt,布尔值”
- python - 无法解释python中打印语句的输出
- linux - 如何创建能够让我查看、修改和附加它创建的文本文件的 Shell 脚本