Home > Enterprise >  Getting error when I am trying to connect my Android Studio to Firebase following the docs
Getting error when I am trying to connect my Android Studio to Firebase following the docs

Time:12-31

Where Should I paste this?

AS in docs it shows to paste this in Root-level (project-level) Gradle file (/build.gradle):

but this is showing error when I am trying to paste this.

allprojects {
  repositories {
    // Make sure that you have the following two repositories
    google()  // Google's Maven repository

    mavenCentral()  // Maven Central repository

  }
}

Following the video given by Firebase website as I have noticed that many things have changed in Android studio so its hard for me to follow the video.

my build.gradle file has these

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.name = "PUCabz"
include ':app'

WHere should I paste the "allprojects repositories" code

CodePudding user response:

I resolved this issue by commenting out 'dependencyResolutionManagement' section which is present in the settings.gradle.

Go to Gradle Scripts -> settings.gradle -> comment out 'dependencyResolutionManagement'

//dependencyResolutionManagement {
//    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
//    repositories {
//        google()
//        mavenCentral()
//    }
//}

Then paste the all project repository in Gradle Scripts -> build.gradle -> paste it below 'plugins' section

like this-

plugins {
    id 'com.android.application' version '7.3.1' apply false
    id 'com.android.library' version '7.3.1' apply false
}


allprojects {
    repositories {
        // Make sure that you have the following two repositories
        google()  // Google's Maven repository
        mavenCentral()  // Maven Central repository
    }
}
  • Related