Home > Back-end >  Latest Android Studio - Problem adding Google Service Gradle plugin to build.gradle file
Latest Android Studio - Problem adding Google Service Gradle plugin to build.gradle file

Time:06-29

I am having trouble adding Google Service Gradle plugin to build.gradle file in latest Android Studio Chipmunk. Specifically I am trying to add classpath 'com.google.gms:google-services:4.3.12'. It seems project level build.gradle file has changed from previous versions. I don't know where to add the above dependency. Any help would be highly appreciated. Thanks.

CodePudding user response:

paste code for your build-script class file in project-level gradle.build file, here is an example :

    /**
     * project-level - build.gradle file -- make sure buildscript is before 
     * plugins
    **/
    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
// your classpath
            classpath 'com.google.dagger:hilt-android-gradle-plugin:2.41'
        }
    }
    
    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    plugins {
        id 'com.android.application' version '7.1.3' apply false
        id 'com.android.library' version '7.1.3' apply false
        id 'org.jetbrains.kotlin.android' version '1.6.20' apply false
    }
    
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }

CodePudding user response:

Examples from my projects.

Project level 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.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
    id 'org.jetbrains.kotlin.jvm' version '1.7.0' apply false
}

Or module level build.gradle:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
    id 'kotlin-android-extensions'
}
  • Related