Home > Mobile >  how can I add google services classpath for firebase in build.gradle of new android studio
how can I add google services classpath for firebase in build.gradle of new android studio

Time:07-14

My project's build.gradle code =

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.2.1' apply false
    id 'com.android.library' version '7.2.1' apply false
}

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

I am trying to add classpath 'com.google.gms:google-services:4.3.13' in my project's build.gradle file but am not getting any space to paste. Even I have tried putting this before and after plugins =

dependencies {
  classpath 'com.google.gms:google-services:4.3.13'
}

Still I am having problem. I also have tried to insert plugins inside dependencies but problem still occurs.

Now, I need a solution.

CodePudding user response:

I am answering my problem just because to help out people who couldn't solve it.

The main thing here is, we have to add the dependencies before the "// Top level build....".

I solved it sometimes before with a help.

The code should be:

dependencies {
  classpath 'com.google.gms:google-services:4.3.13'
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.2.1' apply false
    id 'com.android.library' version '7.2.1' apply false
}

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

This is the main solve. You can add more classpaths if you want.

CodePudding user response:

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.3.13'
    }
}

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.2.1' apply false
    id 'com.android.library' version '7.2.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
}

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

happy code!!!

  • Related