You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Firebase配置报错:Failed to resolve: com.google.firebase:firebase-core:12.0.1

Fixing "Failed to resolve: com.google.firebase:firebase-core:12.0.1" Error

I've run into this exact error before when working with older Firebase versions—let's walk through the most common fixes that usually resolve this issue, especially since you've already confirmed your SDK Manager is in good shape:

1. Ensure the Google Maven Repository is Added to Your Project-Level Build.gradle

Firebase artifacts for older versions like 12.0.1 are hosted exclusively on Google's Maven repository, so if your project isn't pointing to it, Gradle can't find the dependency.

Open your project's root build.gradle file (not the app module one) and verify it includes the google() repository in both the buildscript and allprojects sections:

buildscript {
    repositories {
        google() // This is mandatory for Firebase
        jcenter() // Optional for legacy projects
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.2' // Use a version compatible with your Firebase version
        classpath 'com.google.gms:google-services:3.2.1' // Match this to your Firebase version (see step 2)
    }
}

allprojects {
    repositories {
        google() // Critical for resolving Firebase dependencies
        mavenCentral()
    }
}

2. Match the Google Services Plugin Version to Firebase 12.0.1

Older Firebase versions require a specific version of the google-services plugin to work correctly. For Firebase 12.0.1, the compatible plugin version is 3.2.1. Using a newer or older plugin version will cause resolution failures.

Update the classpath for com.google.gms:google-services in your project-level build.gradle to match this version (as shown in the code snippet above).

3. Verify Your App Module's Build.gradle Configuration

Make sure you've applied the Google Services plugin at the very bottom of your app module's build.gradle file—this is a common oversight:

apply plugin: 'com.android.application'
// ... other app configurations, dependencies, etc. ...

dependencies {
    // Your Firebase core dependency
    implementation 'com.google.firebase:firebase-core:12.0.1'
}

// This line must be the last one in the file
apply plugin: 'com.google.gms.google-services'

4. Invalidate Android Studio Caches and Restart

Corrupted local caches can sometimes block Gradle from resolving dependencies properly. Here's how to fix that:

  • Go to File > Invalidate Caches...
  • Select "Invalidate and Restart"
  • Let Android Studio restart and rebuild your project automatically

5. Consider Upgrading to a Newer Firebase Version (Optional)

Version 12.0.1 is quite outdated (released in 2018). If your project allows, upgrading to a newer version using the Firebase Bill of Materials (BoM) will eliminate most version conflict issues entirely:

dependencies {
    // Import Firebase BoM to manage compatible versions automatically
    implementation platform('com.google.firebase:firebase-bom:32.7.0')
    
    // Add Firebase dependency without specifying a version
    implementation 'com.google.firebase:firebase-analytics' // Replaces firebase-core in modern Firebase versions
}

The BoM ensures all Firebase libraries you use are on compatible versions, so you won't have to worry about manual version matching anymore.


内容的提问来源于stack exchange,提问作者Fox

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:25:49