我已经根据文档添加了所有必需的依赖项,当我试图使用FirebaseAuth变量时,它显示无法解析符号'FirebaseAuth'.我也导入了所需的软件包。我已经在build.gradle(app)中添加了这些依赖项,请检查-构建。gradle (app) code -
dependencies {
implementation platform('com.google.firebase:firebase-bom:31.1.1')
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-database:20.1.0'
implementation 'com.google.firebase:firebase-core:21.1.1'
implementation 'com.google.firebase:firebase-common-ktx:20.2.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-storage'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
}
我正在添加其他gradle文件的代码,以防它可能是错误的原因构建。gradle(项目)代码-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
dependencies {
// Add the dependency for the Google services Gradle plugin
classpath 'com.google.gms:google-services:4.3.13'
}
}
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
}
//task clean(type: Delete) {
// delete rootProject.buildDir
//}
allprojects {
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
}
设置。gradle代码——
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
//dependencyResolutionManagement {
// repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
// repositories {
// google()
// mavenCentral()
// }
//}
rootProject.name = "PUCabz"
include ':app'
当我尝试运行应用程序时,它在日志cat-中显示此错误Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
尝试添加此依赖项并尝试是否有效
implementation 'com.google.firebase:firebase-auth-ktx:21.1.0'