'Gradle can not find firebase auth ktx library in android

As you can see below, I have encounter this error when I try to download missing files inside firebase auth.ktx library otherwise I can not reach any document written about classes, methods or properties.

Executing tasks: [DownloadSources] in project C:\Users\legol\AndroidStudioProjects\LoginSignUpCompose

Task :app:DownloadSources FAILED 1 actionable task: 1 executed

FAILURE: Build failed with an exception.

  • Where: Initialization script 'C:\Users\legol\AppData\Local\Temp\ijmiscinit7.gradle' line: 25

  • What went wrong: Execution failed for task ':app:DownloadSources'.

Could not resolve all files for configuration ':app:downloadSources_5a704857-f630-4789-a501-06f173a810ef'. Could not find com.google.firebase:firebase-auth-ktx:21.0.2@aar. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-auth-ktx/21.0.2@aar/[email protected] - https://repo.maven.apache.org/maven2/com/google/firebase/firebase-auth-ktx/21.0.2@aar/[email protected] Required by: project :app

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s

this is my Project built file

buildscript {
    ext.kotlin_version = '1.6.0'
    ext {
        compose_version = '1.2.0-alpha05'
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.3.10'  // Google Services plugin
        classpath 'com.google.dagger:hilt-android-gradle-plugin:2.40.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.1.2' apply false
    id 'com.android.library' version '7.1.2' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}



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

and that one is Model built file

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'com.google.gms.google-services'
    id 'dagger.hilt.android.plugin'
    id 'kotlin-kapt'
}


android {
    compileSdk 31

    defaultConfig {
        applicationId "com.example.loginsignupcompose"
        minSdk 21
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        freeCompilerArgs = ['-Xjvm-default=compatibility']
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {
    def nav_version = "2.4.1"


    implementation 'androidx.core:core-ktx:1.7.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
    implementation 'androidx.activity:activity-compose:1.4.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"

    //Hilt DI
    implementation("com.google.dagger:hilt-android:2.40.4")
    kapt "com.google.dagger:hilt-android-compiler:2.40.4"
    //Hilt Navigation integration with compose
    implementation("androidx.hilt:hilt-navigation-compose:1.0.0")

    // Navigation Implementation
    implementation "androidx.navigation:navigation-compose:$nav_version"


    //Accompanist Permissions
    implementation "com.google.accompanist:accompanist-permissions:0.24.3-alpha"
    //Coil image Library
    implementation "io.coil-kt:coil-compose:2.0.0-rc01"

    // Material Icons
    implementation "androidx.compose.material:material-icons-extended:1.2.0-alpha05"
    // ViewModel Compose
    implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.5.0-alpha04"

    // kotlin coroutines
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0"
    // Source: https://github.com/Kotlin/kotlinx.coroutines/tree/master/integration/kotlinx-coroutines-play-services
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.0'
    //implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2"

    // Import the BoM for the Firebase platform
    implementation platform('com.google.firebase:firebase-bom:29.2.1')

    // Declare the dependency for the Cloud Firestore library
    // When using the BoM, you don't specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-firestore-ktx'
    // Auth library
    implementation "com.google.firebase:firebase-auth-ktx:21.0.2"


    implementation "androidx.core:core-ktx:1.7.0"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

}


Solution 1:[1]

The correct download URL is https://maven.google.com/com/google/firebase/firebase-auth-ktx/21.0.2/firebase-auth-ktx-21.0.2.aar

I assume you are getting the wrong URLs because you missed to add the Google repository to your project. Add in your top-level build file build.gradle the following section:

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Robert