无法找到 com.google.firebase:firebase-core:9.0.0。

31

在遵循有些不一致的指示此处此处后,当执行gradle同步时出现错误,提示could not find com.google.firebase:firebase-core:9.0.0

有什么想法为什么会发生这种情况吗?

app/build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
        free {
            applicationId ... 
        }

        paid {
            applicationId ... 
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:support-v4:23.3.0'

    freeCompile 'com.google.firebase:firebase-core:9.0.0'
    freeCompile 'com.google.firebase:firebase-ads:9.0.0:9.0.0'
}

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

根目录/build.gradle

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        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
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

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

3
如果这个问题比其他问题先被提出来,那它怎么会被认为是一个重复的问题呢? - chris
因为另一个问题有更多(并且获得更高的赞同票)的答案。 - Moshe Katz
1
这很可能是因为它被标记为重复。 - chris
添加 Firebase 现在非常容易,请参考此处 https://dev59.com/QFoU5IYBdhLWcg3wO1QW#41564507 - karanatwal.github.io
1个回答

54

首先,您需要更新 Play Services Library 至rev.30:

enter image description here

然后,您在此行中遇到了一个小问题:

freeCompile 'com.google.firebase:firebase-ads:9.0.0:9.0.0'

你可能需要将它更正为这样:

freeCompile 'com.google.firebase:firebase-ads:9.0.0'

30
您还需要安装Google存储库。 - Scott
谢谢你的帮助。我缺少了Play服务。你也是对的,关于Firebase的更正。看起来官方文档有一个错误。 - chris
8
我已更新了所有的库,但仍然出现错误。 - Aditay Kaushal
你如何打开SDK管理器?我认为我在Android Studio中查看它,但我的界面看起来非常不同。另外,没有Google存储库的选项?! - K-Dawg

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