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
Adding the
google-services
plugin to theplugins {}
block is causing errors. The alternate way that I’ve found is:buildscript {}
block, add thisIn step 1, using
mavenCentral()
is necessary as thegoogle-services
plugin downloads the linked dependencies likegson
from maven central 🙂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.
your build.gradle(Project:) looks like
your build.gradle(Module:) looks like
your settings.gradle(Project Settings) looks like