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

Android Studio 3.1.1中找不到com.google.firebase:firebase-database:12.0.1求助

Fixing "Could not find com.google.firebase:firebase-database:12.0.1" in Android Studio 3.1.1

Hey there, let's work through this frustrating error you're facing. I've dealt with similar dependency issues when working with older Android Studio versions and Firebase SDKs, so here are the most reliable fixes to try:

1. Verify Google Maven Repository is Configured Correctly

Firebase SDKs (including version 12.0.1) are hosted on Google's Maven repository, not just JCenter. Make sure your top-level build.gradle includes this repository—this is a common oversight.

Here's how your top-level build file should look:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google() // Or use maven { url "https://maven.google.com" } for older Gradle versions
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1'
        // Match this plugin version to your Firebase SDK: 12.0.1 needs 4.0.1
        classpath 'com.google.gms:google-services:4.0.1'
    }
}

allprojects {
    repositories {
        google() // This must come before JCenter for priority
        jcenter()
    }
}

2. Ensure Google Services Plugin Version Matches Firebase SDK

The google-services plugin version has to align with your Firebase SDK version. For Firebase 12.0.1, the correct plugin version is 4.0.1. Using a mismatched version (too new or too old) will break dependency resolution.

3. Clean Android Studio Cache and Restart

Cached data can often cause false "not found" errors. Let's clear it out:

  • Go to File > Invalidate Caches / Restart
  • Select Invalidate and Restart from the popup
  • Once Studio reboots, re-sync your project with Gradle

4. Double-Check Module-Level Dependency Setup

Make sure your Module: app build.gradle has the correct dependency declaration and the Google Services plugin applied at the end:

dependencies {
    // Your other app dependencies...
    implementation 'com.google.firebase:firebase-database:12.0.1'
}

// Critical: This line must be at the END of the file
apply plugin: 'com.google.gms.google-services'

Typos in the dependency string (like missing a colon or wrong version number) are easy to miss—double-check every character!

5. Update Google Repository in SDK Manager

Outdated Google Repository files can prevent Gradle from finding Firebase SDKs:

  1. Open Tools > SDK Manager
  2. Switch to the SDK Tools tab
  3. Check the box for Show Package Details
  4. Find Google Repository and make sure you have a version that supports Firebase 12.0.1 (the latest available version will work)
  5. Click Apply to install/update

If none of these steps work, try replacing google() with maven { url "https://maven.google.com" } in both buildscript and allprojects repositories—some older Gradle versions in Android Studio 3.1.1 don't recognize the shorthand google() command.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 04:13:13