androidfirebaseandroid-studiobuild.gradle

can't sync gradle to use firebase because line 2 is already requested


i'm trying to sync after manually adding firebase dependencies in the gradle project file but sync failed because it is said : "plugin with id 'com.goggle.gms.goggle-services' already requested at line 2 :5" terminal screenshot

here is my gradle project code :

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.google.gms.google.services) apply false
id 'com.google.gms.google-services' version '4.4.2' apply false }

Solution

  • You are mixing the old way to declare dependencies directly in the gradle file with the new approach that uses a version catalog to define all versions and artifacts at a single place. You can then just reference an entry from the version catalog instead of explicitly using the dependency.

    It seems that the version catalog entry for libs.plugins.google.gms.google.services is the com.google.gms.google-services, the same that you also use the next line. Remove the latter and it should work again.

    You should probably take the time and completely migrate your build files to use the version catalog instead of mixing the two approaches. Google published a migration guide for Android apps that you can use.