androidfirebaseandroid-gradle-pluginfirebase-authenticationandroid-gradle-3.0

Could not resolve dependency for 'com.google.firebase:firebase-auth:16.0.3'


I am trying to add firebase authentication to my project. I am getting following errors while syncing build.gradle:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.firebase:firebase-auth:16.0.3.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.firebase:firebase-auth:16.0.3.
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.firebase:firebase-auth:16.0.3.
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.firebase:firebase-auth:16.0.3.
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.firebase:firebase-auth:16.0.3.

My app level gradle file is below:

  apply plugin: 'com.android.application'

    android {
        compileSdkVersion 26
        defaultConfig {
            applicationId "com.example.muzammil.maptestingproject"
            minSdkVersion 15
            targetSdkVersion 24
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        productFlavors {
        }
    }

    dependencies {
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation 'com.android.support:appcompat-v7:26.1.0'
        implementation 'com.google.android.gms:play-services-maps:15.0.1'
        implementation 'com.google.android.gms:play-services-vision:15.0.2'
        implementation 'com.google.android.gms:play-services-location:15.0.1'
        implementation 'com.google.android.gms:play-services-maps:15.0.1'


        implementation 'com.google.firebase:firebase-core:16.0.3'
        implementation 'com.google.firebase:firebase-database:16.0.1'
        implementation 'com.android.support:design:26.1.0'
        implementation 'com.android.support.constraint:constraint-layout:1.1.2'
        implementation 'com.google.firebase:firebase-auth:16.0.3'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    }
    apply plugin: 'com.google.gms.google-services'

The project level gradle file is :

 buildscript {

        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.3'
           classpath 'com.google.gms:google-services:4.0.1'
        }
    }

    allprojects {
        repositories {
            google()
            jcenter()
 maven { url 'https://jitpack.io' }
        }
    }

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

Solution

  • In project level gradle file try to update google-services plugin to latest version:

    buildscript {
    
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.3'
            classpath 'com.google.gms:google-services:4.1.0' // update version
        }
    }