【问题标题】:Error: Could not parse the Android application Module's Gradle Config. Resolve or resync (no repositories in build gradle app)错误:无法解析 Android 应用程序模块的 Gradle 配置。解析或重新同步(构建 gradle 应用程序中没有存储库)
【发布时间】:2022-07-17 07:07:04
【问题描述】:

我正在尝试在我的 android 项目中设置 Firebase。我收到此错误:enter image description here

无法解析 Android 应用程序模块的 Gradle 配置。解决 gradle 构建问题和/或重新同步。

一直在网上寻找修复,其中大多数正在删除 build.gradle 文件中的 jcenter()。我在我的 build.gradle 中没有 jcenter() 或任何其他存储库。

我尝试按照 Firebase 的手册进行操作,但事情变得更加混乱。 我的 android studio 版本可能有问题吗? 我正在使用 Android Studio 北极狐 | 2020.3.1 补丁 4。 Android gradle 插件版本:7.0.4 Gradle 版本:7.0.2

这是我的构建 gradle 项目:

 // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.4'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

构建 gradle 模块(应用):

plugins {
    id 'com.android.application'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.example.autentikacija"
        minSdk 21
        targetSdk 32
        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
    }
    compileSdkVersion 32
    buildToolsVersion '30.0.2'
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
    implementation 'com.google.android.gms:play-services-maps:18.0.1'
    testImplementation 'junit:junit:'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

任何帮助表示赞赏。

【问题讨论】:

  • 解决办法是什么?

标签: android firebase authentication firebase-authentication build.gradle


【解决方案1】:

我遇到了和你一样的问题,我搜索并找到了the website of Firebase 上的步骤。我希望它也对你有用。

【讨论】:

  • 很高兴您分享了您的源代码。但是,最好包含本文中的实际答案。
  • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
【解决方案2】:

其实你可以把compileSdk改成31,也可以保持32但是你需要把Gradle Wrapper改成

distributionUrl=https://services.gradle.org/distributions/gradle-7.0.2-bin.zip

这对我有用,我希望它也对你有用

【讨论】:

    【解决方案3】:

    我面临同样的问题。我尝试了将近 2 天来解决它。只需删除您的 testImplementation 'junit:junit:' 从 build.gradle(module) 依赖并再次同步。这对我有用。

    【讨论】:

      【解决方案4】:

      只需将 compileSdk 从 32 更改为 31 即可。无需删除任何依赖项。

      【讨论】:

        【解决方案5】:

        删除这一行

        testImplementation 'junit:junit:'

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-01-23
          • 1970-01-01
          • 2023-03-26
          • 2017-12-29
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多