Fox
Fox

Reputation: 103

Firebase set up- error: Failed to resolve: com.google.firebase:firebase-core:12.0.1

I'm build an app that uses in Firebase system. When I started enter the code of Firebase in my app I got this error:

"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>"

I looked for this error and I find this but I checked my SDK manager and all is fine I don't know what my problem with my code.
Here my code for 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'

And here my code for 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
}

Can someone help me please?

Upvotes: 2

Views: 2088

Answers (2)

Ajay Kulkarni
Ajay Kulkarni

Reputation: 3039

In My case, I added google() as suggested in accepted answer. I also changed distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip to distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip in gradle-wrapper.properties file.

Upvotes: 0

ישו אוהב אותך
ישו אוהב אותך

Reputation: 29794

You need to add the google() maven inside your allProjects block in your project build.gradle like this:

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

repositories {
    ...
}

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

Upvotes: 3

Related Questions