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

203,879

Solution 1

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

Solution 2

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
    }
}

Solution 3

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

Solution 4

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.

Solution 5

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'
Share:
203,879
Lakshmi
Author by

Lakshmi

Updated on November 28, 2021

Comments

  • Lakshmi
    Lakshmi over 2 years

    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

  • Lakshmi
    Lakshmi over 7 years
    ads are not showing up in real device.I followed below link to integrate ads firebase.google.com/docs/admob/android/quick-start
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    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!
  • Lakshmi
    Lakshmi over 7 years
    still ads are not seen in real device
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    You add this classpath 'com.google.gms:google-services:3.0.0' in project.gradle?
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    Following this link: firebase.google.com/docs/admob/android/quick-start, you need this classpath or your ads not working...
  • Lakshmi
    Lakshmi over 7 years
    this is my app gradle code codepaste.net/gf2qe3.Is it correct?
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    Show me your app.gradle and your project.gradle, the last url doesn't work!
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    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!
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    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!
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    Then it's other question, show us your error and update your post! Thanks!
  • Lakshmi
    Lakshmi over 7 years
    i have updated my question click link of an image named error
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    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!
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    And revision from library?
  • Lakshmi
    Lakshmi over 7 years
    which library? there are three libraries Google play billing library,Google play licensing library,Google play apk expansion library
  • Lakshmi
    Lakshmi over 7 years
    i have installed google play services.only above 3 libraries are present.There is no google play services library
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    See photo in my updated answer, above check you can see Google play services library, what is your rev version?
  • Lakshmi
    Lakshmi over 7 years
    I have installed latest version 36
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    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 services
  • Lakshmi
    Lakshmi over 7 years
    I have installed that 33 version
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    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!
  • Lakshmi
    Lakshmi over 7 years
    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 error
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    Now is correct, clean and rebuild, then show me your error it's the same?
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    Add compile 'com.google.android.gms:play-services:9.6.1' in your dependencies... I said at start of post! ;(
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    Show me your final app.gradle plz
  • Lakshmi
    Lakshmi over 7 years
    even if add apply plugin at the bottom still showing error
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    Copy my app.gradle from my answer! And say me ;)
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    You add your google-services.json file in your project?
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    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!
  • Lakshmi
    Lakshmi over 7 years
    sorry there was internet connection problem
  • Lakshmi
    Lakshmi over 7 years
    I have added google-services json file in my app folder
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    Now, you has correct libraries... This problem is other, I think it's with liked fire base with your app...
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    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?
  • Lakshmi
    Lakshmi over 7 years
    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.html
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    Add in your app.gradle in defaultConfig { multiDexEnabled true }. If you solve this error please close your post, thanks!
  • Lakshmi
    Lakshmi over 7 years
    I have followed link .i have added code in dependencies and android manifest file.Should i delete them?
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    You can see your app.gradle update in my answer ;)
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    This package name is equal to firebase package name? :O Or now it works?
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    This package name is equal to firebase package name?
  • Lakshmi
    Lakshmi over 7 years
    I have changed package name in google services json file downloaded from firebase console
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    The xml that contains your adview, has this line on XML: xmlns:ads="schemas.android.com/apk/res-auto" ?
  • Lakshmi
    Lakshmi over 7 years
    I think the problem is with google services json file package name and firebase console package name.any idea how to solve it?
  • Lakshmi
    Lakshmi over 7 years
    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 file
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    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...
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    Before do nothing, you change all name packages inside json file? :O
  • Lakshmi
    Lakshmi over 7 years
    i have changed my package name to the package name in android manifest xml
  • Lakshmi
    Lakshmi over 7 years
    But when i link to firebase it is in the form of com.packagename.android
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    This one com.packagename.android is a suggestion from firebase... Your package name is good!
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    My google-services.json in oauth_client has too: "android_info": { "package_name": "yourPackage", "certificate_hash": "yourHash" } Add this one ;)
  • Lakshmi
    Lakshmi over 7 years
    can u edit and send me google services json .my package name is numbermania
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    Just add this one inside oauth_client part! ;)
  • Lakshmi
    Lakshmi over 7 years
    what is yourpackage? what is certificate hash and your hash.
  • Lakshmi
    Lakshmi over 7 years
    In my link to firebase it is in capital letters as NumberMania but originally it is in small letters numbermania
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    cerificate hash it's a var name and your hash is your SHA1 key
  • Lakshmi
    Lakshmi over 7 years
    please edit my json file.i could not understand your answer
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    "oauth_client": [ { "client_id": "791746437202-4t8b5449cj270cas8e8u2klsjbv9mj3m.apps.googleus‌​ercontent.com", "client_type": 3, "android_info": { "package_name": "com.example.personal.numbermania", "certificate_hash": "your_SHA1" } } ],
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    Now add your SHA-1 key and rebuild project! :)
  • Lakshmi
    Lakshmi over 7 years
    what is SHA-1 key and where should i add it?
  • Lakshmi
    Lakshmi over 7 years
    what is certificate_hash ?
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    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... :(
  • Merlí Escarpenter Pérez
    Merlí Escarpenter Pérez over 7 years
    To obtain sha1 follow this link: stackoverflow.com/questions/5488339/…
  • AXSM
    AXSM over 7 years
    @subrahmanyam-boyapati Why at the bottom? what's the deal? I think is more important to explain why
  • Ajay B
    Ajay B almost 6 years
    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?
  • Joel Broström
    Joel Broström over 5 years
    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."
  • Kapil Soni
    Kapil Soni about 5 years
    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]
  • laurent
    laurent about 5 years
    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!
  • laurent
    laurent about 5 years
    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).
  • t3chb0t
    t3chb0t about 4 years
    Ooops, I used the app build.gradle.
  • Aldan
    Aldan over 3 years
    I doubt that position determines the issue.
  • Chris
    Chris over 3 years
    Version: classpath 'com.google.gms:google-services:4.3.5 Newest Version number here: 'developers.google.com/android/guides/google-services-plugin
  • Ali Yar Khan
    Ali Yar Khan about 3 years
    it shows these depricated warnings registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)