androidfirebasekotlingradlegoogle-play-services

Attempt to implement Google instruction to connect Firebase failed - "Plugin with id 'com.android.application' was already requested at line 1""


This is an ordinary Java project to Android, I just want to connect Firebase to my project.
I try to implement this instruction step-by-step

Google instuction

And currently, I have exactly what Google requires:

In top-level I have in build.gradle.kts:

plugins {   
    alias(libs.plugins.android.application) apply false   
    id("com.google.gms.google-services") version "4.4.2" apply false  
}

In app/build.gradle.kts:

plugins {   
   id("com.android.application")   
   alias(libs.plugins.android.application)   
   id("com.google.gms.google-services")   
}   

I also placed google-service.json inside and made synchronization as Google requires

synchronisation

After I passed all the steps in Google instructions carefully my project became unworkable and broken. Error message:

Plugin with id 'com.android.application' was already requested at line 1

I'm sorry, what's going wrong?


Solution

  • You're getting that error because of duplicate code. In your app/build.gradle.kts file, please remove the first line:

    plugins {   
       //id("com.android.application") //👈
       alias(libs.plugins.android.application)   
       id("com.google.gms.google-services")   
    }