android studio firebase 错误:“无法解析 Android 应用程序模块的 Gradle 配置。解决 gradle 构建问题和/或重新同步。”

时间:2021-06-08 12:02:33

标签: android firebase gradle build

这是我第一次在 android studio 中使用 firebase,我想使用实时数据库。当我在助手中点击连接到 firebase 时,我收到消息 "Could not parse the Android Application Module's Gradle config. Resolve gradle build issues and/or resync." 我在这里看到了很多答案,每个人都会删除不同的内容。

我不知道应该从我的模块中删除什么,我可以使用你的帮助。

我的 build.gradle 模块

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.covid19gate"
        minSdkVersion 21
        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
    }
    buildFeatures {
        viewBinding true
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
    implementation 'androidx.navigation:navigation-fragment:2.3.5'
    implementation 'androidx.navigation:navigation-ui:2.3.5'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.yarolegovich:discrete-scrollview:1.5.1'

    implementation("com.squareup.okhttp3:logging-interceptor:4.9.1")
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

1 个答案:

答案 0 :(得分:1)

转到“项目”(不是应用程序)的 build.gradle 文件

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

并从那里删除 jcenter()