Home > database >  how to add com.google.gms:google-services:4.3.14 in my android project?
how to add com.google.gms:google-services:4.3.14 in my android project?

Time:11-24

When I read this doc: https://developers.google.com/android/guides/google-services-plugin they say :

As part of enabling Google APIs or Firebase services in your Android application you may have to add the google-services plugin to your build.gradle file:

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

then they say also :

Add dependencies for basic libraries required for the services you have enabled. This step requires that you apply the Google Services Gradle plugin in your app/build.gradle file, like so: apply plugin: 'com.google.gms.google-services'

so i start a blank new android project in the very last version of android studio and I have for the root build.gradle:

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

and in app/build.gradle:

plugins {
    id 'com.android.application'
}

android {
    namespace 'app.dependencieswalker'
    compileSdk 32

    defaultConfig {
        applicationId "app.dependencieswalker"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
        implementation "com.alcinoe:alcinoe-firebase:1.0.0"
}

so where I must add the

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

and

apply plugin: 'com.google.gms.google-services' ?

CodePudding user response:

In your root build.gradle file in the plugins block add

plugins {
    //....
    id 'com.google.gms.google-services' version '4.3.14' apply false
}

Then apply it in the module build.gradle file with:

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
}

CodePudding user response:

You should modify the root build.gradle as follows:

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

buildscript {
    repositories {
        mavenCentral()
        google()
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.3.10'

    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

and the app/build.gradle

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services' version '4.3.14' apply true
}

android {
    namespace 'app.dependencieswalker'
    compileSdk 32

    defaultConfig {
        applicationId "app.dependencieswalker"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
        implementation "com.alcinoe:alcinoe-firebase:1.0.0"
        
}
  • Related