Plugin with id 'com.google.gms.google-services' not found
Asked Answered
F

23

186

I have followed this link to integrate ads in my app. But it shows this error:

error image

This is my build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"





defaultConfig {
    applicationId "com.example.personal.numbermania"
    minSdkVersion 10
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
}
buildTypes {
    debug
            {
                debuggable true
            }
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.google.firebase:firebase-ads:9.6.0'

}

}

ads are not showing up in real device.please help me This is my error after i updated classpath error

Finegrained answered 6/10, 2016 at 9:41 Comment(6)
Simply you need to generate google services json file from console developers google and put it inside app directory.Hellenist
Check this and follow steps given here #34401643Hellenist
where is google services found?Finegrained
Click the link given in answer select your project and get configuration file it will ask you to download file.Hellenist
Any of the Answer Didn't work. But reset Android Studios solved Check this to reset:- #19384533Solifidian
First, add Firebase to your app, you'll get detailed steps on what to do including downloading the required JSON and putting it in your app root folder. Then try this, that should fix the issue.Estancia
A
259

Had the same problem.

Fixed by adding the dependency

classpath 'com.google.gms:google-services:3.0.0'

to the root build.gradle.

https://firebase.google.com/docs/android/setup#manually_add_firebase

Angloindian answered 11/2, 2017 at 9:33 Comment(7)
The documents also stress the importance of adding the apply plugin: 'com.google.gms.google-services' at he bottom of the file by writing it in italic. "In your module (app-level) Gradle file (usually app/build.gradle), add a line to the bottom of the file."Appendicitis
sir i got error after add above in build.gradle: > Could not find method lasspath() for arguments [com.google.gms:google-services:3.0.0]Vivien
I'm also getting the lasspath error and all I can find on the internet are Kapil Soni's messages that are all left without an answer. So now there's the two of us, sir, you're not alone!Sauternes
I guess it won't be useful to anybody but Kapil and me, but to fix the lasspath issue just run grep -R 'lasspath' * | grep -i --invert-match 'classpath' and you should find the file and line that's causing an issue (basically, a typo).Sauternes
Version: classpath 'com.google.gms:google-services:4.3.5 Newest Version number here: 'developers.google.com/android/guides/google-services-pluginShaunda
it shows these depricated warnings registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)Painty
What really helped me was this: firebase.google.com/docs/android/…Norbert
B
86

Setting up Gradle plugins in the root build.gradle meanwhile works alike this:

plugins {
    id "com.android.application" version "8.3.2" apply false
    id "com.android.library" version "8.3.2" apply false
    id "com.google.gms.google-services" version "4.4.1" apply false
}

Then they can be applied in a module:

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

Unless some Gradle plugin may depend on it, one can remove/skip the buildscript block altogether, but it's still good for defining project-wide version numbers in buildscript.ext:

buildscript {
    ext {
        agp_version = '8.3.2'
        gms_version = '4.4.1'
    }
}

plugins {
    id 'com.android.application' version "$agp_version" apply false
    id 'com.android.library' version "$agp_version" apply false
    id "com.google.gms.google-services" version "$gms_version" apply false
}

Please note that meanwhile the suggested way to deal with version numbers is to maintain a version-catalog in file gradle/libs.versions.toml; for example and the documentation: https://mcmap.net/q/137281/-media3-dependencies-for-build-gradle-kts-for-android-studio-2023-2-1-patch-2

Boring answered 27/2, 2022 at 14:4 Comment(2)
i was stucked at android studio chipmunk as its new..thanks for the accurate answerAxseed
Bonus marks for doing it the more "modern" way, just using plugins block in root build.gradle file, and not doing buildscript classpath.Redemptioner
D
67

Add classpath com.google.gms:google-services:3.0.0 dependencies at project level build.gradle

Refer the sample block from project level build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
Deva answered 8/11, 2017 at 3:14 Comment(1)
i had error because i used double quote "" instead of single ''Would
L
33

You can find the correct dependencies here apply changes to app.gradle and project.gradle and tell me about this, greetings!


Your apply plugin: 'com.google.gms.google-services' in app.gradle looks like this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"

    defaultConfig {
        applicationId "com.example.personal.numbermania"
        minSdkVersion 10
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"

        multiDexEnabled true
    }

    dexOptions {
        incremental true
        javaMaxHeapSize "4g" //Here stablished how many cores you want to use your android studi 4g = 4 cores
    }

    buildTypes {
        debug
                {
                    debuggable true
                }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:24.2.1'
        compile 'com.android.support:design:24.2.1'
        compile 'com.google.firebase:firebase-ads:9.6.1'
        compile 'com.google.firebase:firebase-core:9.6.1'
        compile 'com.google.android.gms:play-services:9.6.1'
}

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

Add classpath to the project's gradle:

classpath 'com.google.gms:google-services:3.0.0'

Google play services library on SDK Manager:

enter image description here

Lucero answered 6/10, 2016 at 11:23 Comment(61)
ads are not showing up in real device.I followed below link to integrate ads firebase.google.com/docs/admob/android/quick-startFinegrained
All components of firebase (ads included) needs this dependencie: compile 'com.google.firebase:firebase-core:9.6.1' following this tutorial(firebase.google.com/docs/android/setup) to install firebase sdk on android. Add, build it and tell me about this, greetings!Ermey
still ads are not seen in real deviceFinegrained
You add this classpath 'com.google.gms:google-services:3.0.0' in project.gradle?Ermey
Following this link: firebase.google.com/docs/admob/android/quick-start, you need this classpath or your ads not working...Ermey
this is my app gradle code codepaste.net/gf2qe3.Is it correct?Finegrained
Show me your app.gradle and your project.gradle, the last url doesn't work!Ermey
I can opened now... But this is the same image that before images... Your app.gradle it's correct I need to see your project.gradle!Ermey
The problem is here classpath 'com.google.gms:google-services:1.3.0-beta1', to use ads in firebase you need to change your classpath to classpath 'com.google.gms:google-services:3.0.0' and finally your gradle is correct!Ermey
Then it's other question, show us your error and update your post! Thanks!Ermey
i have updated my question click link of an image named errorFinegrained
Click in Help button from Android Studio and then click on Check for updates, open your SDK and install correct library from google services, tell me about this!Ermey
And revision from library?Ermey
which library? there are three libraries Google play billing library,Google play licensing library,Google play apk expansion libraryFinegrained
i have installed google play services.only above 3 libraries are present.There is no google play services libraryFinegrained
See photo in my updated answer, above check you can see Google play services library, what is your rev version?Ermey
I have installed latest version 36Finegrained
Above check Google repository I asked from Google play services it's impossible that you have version 36 when max is 33, I think you talk about Google repository... Say image the other library you can see is Google play servicesErmey
I have installed that 33 versionFinegrained
I can see the problem I think... The problem is in your apply pluguin apply plugin: 'com.google.gms.google-services'... Your is inside on Android {}... Just put outside this... See my updated answer!Ermey
i have changed my code as u have suggested here is the app build gradle code codepaste.net/s9m257. Is this correct? it is showing an errorFinegrained
Now is correct, clean and rebuild, then show me your error it's the same?Ermey
Add compile 'com.google.android.gms:play-services:9.6.1' in your dependencies... I said at start of post! ;(Ermey
Show me your final app.gradle plzErmey
even if add apply plugin at the bottom still showing errorFinegrained
Copy my app.gradle from my answer! And say me ;)Ermey
You add your google-services.json file in your project?Ermey
Then here is the problem... xD To connect Firebase project with android you need to generate a google-services.json file and add on your project... How? It's easy... Go to Firebase console inside project configuration, inside android applications then select your packcagename and press the button download google-services.json, then add this one in app folder. Rebuild and say me it's work!Ermey
sorry there was internet connection problemFinegrained
I have added google-services json file in my app folderFinegrained
Now, you has correct libraries... This problem is other, I think it's with liked fire base with your app...Ermey
When you create a new app on firebase, you add your package name correctly? How to know it? Open your manifest.xml and open too your google-services.json in client area search package_name, the both are equal?Ermey
this is the error Error:The number of method references in a .dex file cannot exceed 64K. Learn how to resolve this issue at developer.android.com/tools/building/multidex.htmlFinegrained
Add in your app.gradle in defaultConfig { multiDexEnabled true }. If you solve this error please close your post, thanks!Ermey
I have followed link .i have added code in dependencies and android manifest file.Should i delete them?Finegrained
You can see your app.gradle update in my answer ;)Ermey
This package name is equal to firebase package name? :O Or now it works?Ermey
This package name is equal to firebase package name?Ermey
I have changed package name in google services json file downloaded from firebase consoleFinegrained
The xml that contains your adview, has this line on XML: xmlns:ads="schemas.android.com/apk/res-auto" ?Ermey
I think the problem is with google services json file package name and firebase console package name.any idea how to solve it?Finegrained
my package name is com.example.personal.numbermania but i have added com.NumberMania.android in firebase console.so i have changed package name maually after i downloaded google-services json fileFinegrained
The problem can be there... If you want to do all correctly, my advice is delete actual android app in firebase and create the new one with correctly package name...Ermey
Before do nothing, you change all name packages inside json file? :OErmey
i have changed my package name to the package name in android manifest xmlFinegrained
But when i link to firebase it is in the form of com.packagename.androidFinegrained
This one com.packagename.android is a suggestion from firebase... Your package name is good!Ermey
My google-services.json in oauth_client has too: "android_info": { "package_name": "yourPackage", "certificate_hash": "yourHash" } Add this one ;)Ermey
can u edit and send me google services json .my package name is numbermaniaFinegrained
Just add this one inside oauth_client part! ;)Ermey
what is yourpackage? what is certificate hash and your hash.Finegrained
In my link to firebase it is in capital letters as NumberMania but originally it is in small letters numbermaniaFinegrained
cerificate hash it's a var name and your hash is your SHA1 keyErmey
please edit my json file.i could not understand your answerFinegrained
"oauth_client": [ { "client_id": "791746437202-4t8b5449cj270cas8e8u2klsjbv9mj3m.apps.googleusercontent.com", "client_type": 3, "android_info": { "package_name": "com.example.personal.numbermania", "certificate_hash": "your_SHA1" } } ],Ermey
Now add your SHA-1 key and rebuild project! :)Ermey
what is SHA-1 key and where should i add it?Finegrained
what is certificate_hash ?Finegrained
Sorry but the gms error (or library error) at start, it's solved, this error is other thing and I can't helps you because I never implement ad's in Android... :(Ermey
To obtain sha1 follow this link: #5488839Ermey
Oh man you saved my day. in my case that was because i didn't add google play service in my sdk manager.Congruency
S
23

Had the same problem.

adding this to my dependency didn't solve

classpath 'com.google.gms:google-services:3.0.0'

Adding this solved for me

classpath 'com.google.gms:google-services:+'

to the root build.gradle.

Subrogation answered 1/7, 2019 at 10:0 Comment(1)
Ooops, I used the app build.gradle.Sandhurst
C
14

simply add "classpath 'com.google.gms:google-services:3.0.0'" to android/build.gradle to look like this

buildscript {
    repositories {
        maven {
            url "https://maven.google.com"
        }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.0.0'

       // NOTE: Do not place your application dependencies here; they belong
       // in the individual module build.gradle files

    }
}

and also add "apply plugin: 'com.google.gms.google-services'" to the end of file in android/app/build.gradle to look like this

apply plugin: 'com.google.gms.google-services'
Coyotillo answered 16/3, 2019 at 16:36 Comment(0)
C
12

Go To Setting > Android SDK > SDK Tools > Google Play Services

enter image description here

Captor answered 8/11, 2019 at 9:40 Comment(1)
This worked for me and was such a simple fix.Monocle
S
10

On upgrading to Android Studio 4.2.1, I was prompted to set dependency:

classpath 'com.google.gms:google-services:4.3.7'

However, this caused "Plugin with id 'com.google.gms.google-services' not found".
Leaving it as follows fixed the problem:

classpath 'com.google.gms:google-services:4.3.5'

EDIT:

This problem has now been fixed in:

classpath 'com.google.gms:google-services:4.3.8'
Sachsse answered 14/5, 2021 at 15:40 Comment(1)
classpath 'com.google.gms:google-services:4.3.8' worked for meDestination
S
8

I'm not sure about you, but I spent about 30 minutes troubleshooting the same issue here, until I realized that the line for app/build.gradle is:

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

and not:

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

Eg: I had copied that line from a tutorial, but when specifying the apply plugin namespace, no colon (:) is required. It's, in fact, a dot. (.).

Hey... it's easy to miss.

Shoreward answered 21/12, 2020 at 19:18 Comment(1)
Man, you saved my day . This was exactly the issueMiniver
V
7

The Google docs during the Android setup process didn't quite work for me. It seems like Google need to update their docs. The only solution that worked for me was:

  1. As part of enabling Google APIs or Firebase services in your Android application you may have to add the google-services plugin to your project level build.gradle file.
dependencies {
    classpath 'com.google.gms:google-services:4.3.14'
    // ...
}

This plugin will allow to process the google-services.json file and produce Android resources that can be used in your application's code. Also, it will allow to install dependencies for Firebase related libraries, which is going to be the next step.

  1. Add this line to the app level build.gradle file:
apply plugin: 'com.google.gms.google-services'

Sources:

Vern answered 19/1, 2023 at 19:57 Comment(0)
S
5

In build.gradle(Module:app) add this code

dependencies {
    ……..
    compile 'com.google.android.gms:play-services:10.0.1’
    ……  
}

If you still have a problem after that, then add this code in build.gradle(Module:app)

defaultConfig {
    ….
    …...
    multiDexEnabled true
}


dependencies {
    …..
    compile 'com.google.android.gms:play-services:10.0.1'
    compile 'com.android.support:multidex:1.0.1'
}
Synecology answered 11/2, 2017 at 12:45 Comment(1)
Result - Adding multiDexEnabled true & compile 'com.android.support:multidex:1.0.1' does not solve the issue. Can you explain how this is supposed to fix the issue?Starlastarlene
F
4

In the app build.gradle dependency, you must add the following code

classpath 'com.google.gms:google-services:$last_version'

And then please check the Google Play Service SDK tools installing status.

Feudist answered 17/9, 2020 at 11:4 Comment(0)
P
4

Ended up on this thread while trying to integrate Firebase with a Flutter application. So, in case you are facing the same problem in Flutter, below steps solved the issue for me.

Disclaimer: first steps are the same as described in the documentation and every answer/tutorial found online. I am just mentioning them on a high level for the sake of keeping my answer consistent.

The actual step that is different and solved the issue is the last one.

  1. Add google-services.json in your flutter_app/android/app directory.
  2. On android/build.gradle add:
repositories {
    google()
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}

dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath 'com.google.gms:google-services:4.3.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
  1. On android/app/build.gradle add:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
  1. On android/app/build.gradle add also the following:
dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    implementation platform('com.google.firebase:firebase-bom:26.3.0')
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-messaging'

    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

You can find a working demo for this here https://gitlab.com/ecocupaegean/ecocupaegean/-/tree/master/, in order to run the app you just need to add your own google-services.json, and specify an API KEY for google maps geolocation API.

Praetor answered 2/5, 2021 at 12:47 Comment(0)
Y
3
apply plugin: 'com.google.gms.google-services'

add above line at the bottom of your app gradle.build.

Yancey answered 7/10, 2016 at 7:24 Comment(2)
@subrahmanyam-boyapati Why at the bottom? what's the deal? I think is more important to explain whyEnrol
I doubt that position determines the issue.Neille
H
2

I changed google-services classpath version from 4.2.0 to 3.0.0

classpath 'com.google.gms:google-services:3.0.0'

Then rebuild the project, Then strangely it suggested me to add firebase core to the project.

Then I added firebase core on the app(module)

implementation 'com.google.firebase:firebase-messaging:16.0.8'

Then the error disappeared magically.

Hay answered 21/3, 2019 at 10:26 Comment(0)
H
2

Non of the answers above helped in my case, but following this tutorial thoroughly did. Maps SDK for Android / Set up an Android Studio project

Hamulus answered 23/4, 2022 at 16:33 Comment(0)
A
2

I have a very simple solution: Go to build.gradle(project) and in dependencies add following class path:

classpath 'com.google.gms:google-services:4.4.0'

Now make sure to add updated service if available >4.4.0 Build again. Done

Adherence answered 2/1, 2024 at 19:11 Comment(0)
H
1

In project's build.gradle add the following

classpath 'com.google.gms:google-services:4.3.3'
Homogeneous answered 3/4, 2021 at 8:2 Comment(0)
W
1

I initially had classpath 'com.google.gms.google-services:4.3.15' and it was not working. It worked when I changed to classpath 'com.google.gms:google-services:4.3.15'.

Woodcock answered 20/6, 2023 at 8:22 Comment(0)
W
1

If you are using build-gradle.kt

add this

    buildscript {
    repositories {
        google()
        mavenCentral()

        // Android Build Server
        maven { url = uri("../nowinandroid-prebuilts/m2repository") }
    }
    dependencies {
        classpath ("com.google.gms:google-services:4.4.0")
    }
}
Willms answered 1/12, 2023 at 4:59 Comment(0)
A
1
id("com.google.gms.google-services")

use this insitead of

id 'com.google.gms.google-servies'

this is applicable and used for latest versions of android studio

Anticline answered 27/1, 2024 at 8:45 Comment(0)
T
1

If you using kts then specify the version in build.gradle.kts

plugins {
    id("com.google.gms.google-services") version "put_version_here"
}
Twoedged answered 28/2, 2024 at 20:25 Comment(0)
O
0

In android bumblebee Just add this code on top in the build.gradle <Project .> file

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

Now try to add plugin in build.gradle <app .> like this

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'com.google.gms.google-services'
}
Oraliaoralie answered 5/5, 2022 at 3:44 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.