skip to Main Content

I’m creating a new application in Android Studio Bumblebee and this defaults to using the new Groovy DSL plugin management in settings.gradle.

I need to be able to use Google Play Services to enable Firebase functionality, however I am running into a build error when applying the com.google.gms.google-play-services plugin using the documentation here: Google Play Services Readme

I have added the following to my settings.gradle file:

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
    }
    plugins {
        id 'com.android.application' version '7.1.0-alpha13'
        id 'com.android.library' version '7.1.0-alpha13'
        id 'org.jetbrains.kotlin.android' version '1.5.31'
        id 'com.google.gms.google-services' version '4.3.10'
    }
}

and the following to my app’s build.gradle file:

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

however when I build the application, I get the following UnknownPluginException:

Plugin [id: 'com.google.gms.google-services', version: '4.3.10'] was not found in any of the following sources:

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.google.gms.google-services', version: '4.3.10'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.google.gms.google-services:com.google.gms.google-services.gradle.plugin:4.3.10')
  Searched in the following repositories:
    Gradle Central Plugin Repository
    Google

I have also tried the legacy method of classpath etc. but this results in a much longer error message regarding dependency resolution.

I’m not sure what I am doing wrong.

2

Answers


  1. Adding the google-services plugin to the plugins {} block is causing errors. The alternate way that I’ve found is:

    1. First, in your root build file (not the one in the app folder), inside the buildscript {} block, add this
    buildscript {
     repositories {
       google()
       mavenCentral()
     }
     dependencies {
       classpath 'com.google.gms:google-services:4.3.10'
     }
    }
    
    1. In the build file in the app folder, apply the plugin like this,
    apply plugin: 'com.google.gms.google-services'
    

    In step 1, using mavenCentral() is necessary as the google-services plugin downloads the linked dependencies like gson from maven central 🙂

    Login or Signup to reply.
  2. By using Android Studio Bumblebee new Groovy DSL plugin management Add below line in build.gradle(Project:) plugins{} section and sync project will solve your problem.

    id 'com.google.gms.google-services' version '4.3.10' apply false
    

    your build.gradle(Project:) looks like

    plugins {
        id 'com.android.application' version '7.1.1' apply false
        id 'com.android.library' version '7.1.1' apply false
        id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
        id 'com.google.dagger.hilt.android' version '2.41' apply false
        id 'com.google.gms.google-services' version '4.3.10' apply false
        id 'com.google.firebase.crashlytics' version '2.8.1' apply false
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    your build.gradle(Module:) looks like

    plugins {
        id 'com.android.application'
        id 'org.jetbrains.kotlin.android'
        id 'org.jetbrains.kotlin.kapt'
        id 'com.google.dagger.hilt.android'
        id 'com.google.gms.google-services'
        id 'com.google.firebase.crashlytics'
    }
    
    android {
        compileSdk 32
    
        signingConfigs {
            config {
                enableV3Signing true
                enableV4Signing true
            }
        }
    }
    

    your settings.gradle(Project Settings) looks like

    pluginManagement {
        repositories {
            gradlePluginPortal()
            google()
            mavenCentral()
        }
    }
    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
        }
    }
    rootProject.name = "MyApp"
    include ':app'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search