无法解析:com.google.firebase:firebase-core-ktx

5

包含错误截图的图片链接

我正在使用 Kotlin 开发我的 Android 应用程序。由于以下错误,我无法完成 Gradle 构建:

无法解析:com.google.firebase:firebase-core-ktx:

我尝试了 StackOverflow 上所有可能的解决方案。我已经从 SDK 管理器中下载了最新的 Google Play 服务。我在所有仓库中都添加了 maven{url...},但仍然无法解决此错误。我甚至尝试在我的实现中添加版本说明。请帮我解决这个问题!

以下是我的 build.gradle 文件内容:

buildscript {
    ext.kotlin_version = "1.4.21"
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.4'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://maven.google.com" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

以下是添加到代码中的依赖关系:

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
    implementation 'androidx.navigation:navigation-fragment:2.3.2'
    implementation 'androidx.navigation:navigation-ui:2.3.2'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2'
    implementation 'androidx.navigation:navigation-ui-ktx:2.3.2'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'de.hdodenhof:circleimageview:3.1.0'
    implementation platform('com.google.firebase:firebase-bom:26.2.0')
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation 'com.google.firebase:firebase-core-ktx'
    implementation 'com.google.firebase:firebase-auth-ktx'
    implementation 'com.google.firebase:firebase-database-ktx:19.6.0'
    implementation 'com.google.firebase:firebase-storage-ktx'
    testImplementation 'junit:junit:4.13.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
2个回答

2

试试这个:

 implementation 'com.google.firebase:firebase-core:16.0.1'

1
谢谢啊!它起作用了。很高兴你抽出时间来帮助我。 - Prateek Ranjan

1
如果您正在使用BOM库,您也可以尝试这种方法。
implementation 'com.google.firebase:firebase-core'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接