首页 > 解决方案 > 无法在 android studio 中设置 firebase

问题描述

因此,我正在尝试设置 firebase 并制作一个应用程序,该应用程序在您打开应用程序后允许基本登录功能,但我的构建失败并显示以下消息:


    Execution failed for task ':app:checkDebugAarMetadata'.
    > Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
       > Could not find com.firebaseui:firebase-ui-firestore:6.4.0.
         Searched in the following locations:
           - https://dl.google.com/dl/android/maven2/com/firebaseui/firebase-ui-firestore/6.4.0/firebase-ui-firestore-6.4.0.pom
           - https://repo.maven.apache.org/maven2/com/firebaseui/firebase-ui-firestore/6.4.0/firebase-ui-firestore-6.4.0.pom
         Required by:
             project :app
    
    Possible solution:
     - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

我的应用级别gradle如下:


    plugins {
        id 'com.android.application'
        id 'kotlin-android'
        id 'com.google.gms.google-services'
        id 'kotlin-android-extensions'
        id 'kotlin-kapt'
    }
    
    android {
        compileSdkVersion 30
        buildToolsVersion "30.0.3"
    
        defaultConfig {
            applicationId "com.example.socialapp"
            minSdkVersion 16
            targetSdkVersion 30
            versionCode 1
            versionName "1.0"
    
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
    
        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 {
            jvmTarget = '1.8'
        }
    }
    
    dependencies {
    
        implementation "androidx.appcompat:appcompat:$rootProject.appCompatVersion"
    
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutines"
        api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutines"
    
        // UI
        implementation "androidx.constraintlayout:constraintlayout:$rootProject.constraintLayoutVersion"
        implementation "com.google.android.material:material:$rootProject.materialVersion"
    
        /* coroutines support for firebase operations */
        implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.1.1'
    
    
        // Import the BoM for the Firebase platform
        implementation platform('com.google.firebase:firebase-bom:26.1.0')
        implementation 'com.google.firebase:firebase-firestore'
        implementation 'com.google.firebase:firebase-auth-ktx'
        implementation 'com.firebaseui:firebase-ui-firestore:6.4.0'
    
        implementation 'com.google.android.gms:play-services-auth:19.0.0'
    
        implementation 'com.github.bumptech.glide:glide:4.12.0'
        annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
    
        // Testing
        testImplementation "junit:junit:$rootProject.junitVersion"
        androidTestImplementation "androidx.arch.core:core-testing:$rootProject.coreTestingVersion"
        androidTestImplementation ("androidx.test.espresso:espresso-core:$rootProject.espressoVersion", {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        androidTestImplementation "androidx.test.ext:junit:$rootProject.androidxJunitVersion"
    }

我的项目级gradle如下:


    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        ext.kotlin_version = "1.5.20"
        repositories {
            google()
            mavenCentral()
        }
        dependencies {
            classpath "com.android.tools.build:gradle:4.2.1"
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath 'com.google.gms:google-services:4.3.8'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            google()
            mavenCentral()
            //jcenter() // Warning: this repository is going to shut down soon
           
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    ext {
        appCompatVersion = '1.2.0'
        constraintLayoutVersion = '2.0.2'
        coreTestingVersion = '2.1.0'
        coroutines = '1.3.9'
        lifecycleVersion = '2.2.0'
        materialVersion = '1.2.1'
        // testing
        junitVersion = '4.13.1'
        espressoVersion = '3.1.0'
        androidxJunitVersion = '1.1.2'
    }

我无法找到此错误消息的确切解决方案,但我遇到了类似错误消息的解决方案,但它们似乎不起作用,任何帮助将不胜感激!

标签: androidfirebasegradlebuild

解决方案


根据文档,您应该从 6.4.0 升级到 7.xx,因此您的 gradle 应该如下所示:

 // FirebaseUI for Cloud Firestore
    implementation 'com.firebaseui:firebase-ui-firestore:7.2.0'

另外,您是否应用了 Google 服务应用插件:“com.google.gms.google-services”并确保您更新了


推荐阅读