java - Firebase 设置-错误 : Failed to resolve: com. google.firebase :firebase-core:12. 0.1

标签 java android firebase gradle

我正在构建一个在 Firebase 系统中使用的应用程序。当我开始在我的应用程序中输入 Firebase 的代码时,出现了这个错误:

"Error:(30, 13) Failed to resolve: com.google.firebase:firebase-core:12.0.1
<a href="openFile:C:/Users/Public/Documents/Jtube2/app/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>"

我查找了这个错误并找到了 this但我检查了我的 SDK 管理器,一切正常我不知道我的代码有什么问题。
这是我的 build.gradle (module:app) 代码:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:design:25.1.0'
    compile 'com.android.support:support-vector-drawable:25.1.0'
    compile 'com.google.firebase:firebase-core:12.0.1'
    testCompile 'junit:junit:4.12'
}

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

这里是我的 build.gradle (Project:myproject) 代码:

repositories {
    jcenter()
    google()
}

dependencies {
    classpath 'com.android.tools.build:gradle:2.3.2'
    classpath 'com.google.gms:google-services:3.0.0'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

有人可以帮帮我吗?

最佳答案

您需要在 project build.gradleallProjects block 中添加 google() maven像这样:

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        ...
    }
}

repositories {
    ...
}

// You need to add the google maven in this block.
allprojects {
    repositories {
        jcenter()
        google()
    }
}

关于java - Firebase 设置-错误 : Failed to resolve: com. google.firebase :firebase-core:12. 0.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49942413/

相关文章:

android - 如何使用 Jetpack Compose 在我的屏幕中使用 9 补丁可绘制对象 (.9.png)?

android - 如何在 TextViews 下正确对齐 ListView

每个文档抖动的 Firebase-firestore 安全规则

javascript - 如何设置 firebase 监听器只监听新添加的 child ?

node.js - 使用 Admin SDK 将文件上传到 Firebase 存储

java - SelectOutPut (AnyLogic) 中代理类型的条件

java - 使用 selenium 和 java 启动 Electron 应用程序

android - 使用 mySQL 运行 monkeyrunner python 脚本

java - 如何使用 StreamTokenizer 确保特定标记之间有空格?

java - 涉及HTTP Basic Authentication的文件下载