当将firebase项目从旧域升级到新的谷歌firebase域时,我得到以下错误。

未能解决:com.google.firebase:firebase-core:9.0.0

我遵循了Firebase文档中提到的步骤,在“将Firebase添加到您的Android项目”主题中,可用库。

解决此错误的选项是什么?


当前回答

dependencies {
    compile 'com.google.android.gms:play-services-maps:11.8.0'
    compile 'com.google.android.gms:play-services-auth:11.8.0'
    compile 'com.google.android.gms:play-services-ads:11.8.0'
    compile 'com.google.firebase:firebase-storage:11.8.0'

}
apply plugin: 'com.google.gms.google-services'


// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {


        maven { url 'https://maven.fabric.io/public' }

        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath 'com.google.gms:google-services:3.1.1'


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

allprojects {
    repositories {
        jcenter()
        google()
    }
}

其他回答

错误:(30,13)Failed to resolve: com.google.firebase:firebase-auth:9.6.1

如果你遇到这个错误,并且你使用的是Android studio 2.2,其中集成了firebase组件,默认的库版本为9.6.0,你正在添加9.6.1等最新的依赖项。您可能需要将com.google.firebase:firebase-auth:9.6.1降级为com.google.firebase:firebase-auth:9.6.0

或者检查您预先安装的firebase的库版本,并确保它与您试图添加或添加到项目中的新库版本相同。

2022年10月更新

com.google。firebase-core已于2022年10月弃用。使用firebase-analytics或firebase- analysis -ktx而不是firebase-core。

firebase-core库已弃用,不会有其他版本 被释放。该SDK包括谷歌Analytics的Firebase SDK。 现在,要使用谷歌Analytics或推荐添加的产品 谷歌Analytics,你需要显式地声明Analytics 依赖:com.google。重火力点:firebase-analytics或 com.google.firebase: firebase-analytics-ktx。

发布说明

我尝试了所有的方法,但没有一种对我有效。更改gradle版本对我来说很有效。

我在gradle-wrapper.properties中更改了以下内容

from

distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

to

distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip

如果使用命令行工具,请执行

sdkmanager 'extras;google;m2repository'
sdkmanager 'extras;android;m2repository'

如果上述所有方法都不起作用,那么在应用级构建中将实现'com.google.firebase:firebase-core:12.0.0'更改为实现'com.google.firebase:firebase-core:10.0.0'。gradle文件。 这肯定会奏效。