Muzzammil Hussain
Muzzammil Hussain

Reputation: 298

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
    }

Upvotes: 0

Views: 6789

Answers (3)

Nikunj
Nikunj

Reputation: 4157

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

Upvotes: 3

Angus
Angus

Reputation: 3748

Since the normal way doesn't work,and assuming you are using Android Studio you could try using the GUI way by:

  1. Clean Project
  2. Rebuild Project
  3. Under the Tools, select Firebase
  4. Authentication
  5. Email and password authentication
  6. Connect to Firebase
  7. Add dependencies
  8. Check your auth status as described

Upvotes: 1

Martin Zeitler
Martin Zeitler

Reputation: 76807

it complains about lack of dependencies for the debugUnitTest, while you don't have any debug build-type specified in your module-level build.gradle. it should look about like this, for example:

buildTypes {
    debug {
        applicationIdSuffix '.debug'
        // signingConfig signingConfigs.debug
        minifyEnabled false
        debuggable true
        jniDebuggable true
        zipAlignEnabled true
        renderscriptDebuggable true
        pseudoLocalesEnabled false
        shrinkResources false
    }

also, consider adding androidTestImplementation "com.android.support.test:rules:1.0.2" as a dependency ...and maybe add testBuildType "debug" to the defaultConfig.

Upvotes: 2

Related Questions