Wednesday, February 1, 2017

Admob + Firebase: Plugin with id 'com.google.gms.google-services' not found.


I was following the instruction in https://firebase.google.com/docs/admob/android/quick-start to add Admob into my Android App.

It sounded as simple as adding two lines into the app level's build.gradle:
...
    dependencies {
            compile fileTree(dir: 'libs', include: ['*.jar'])
            compile 'com.android.support:appcompat-v7:xx.x.x'
            compile 'com.google.firebase:firebase-ads:10.0.1'
        }
...

apply plugin: 'com.google.gms.google-services'
 However, after doing the Sync as the IDE required, this error was encountered:

   Gradle sync failed: Plugin with id 'com.google.gms.google-services' not found.

It seems the tutorial has left out some details. After I added the following two lines, this problem was solved.

In the Project level build.gradle, add dependency: classpath 'com.google.gms:google-services:3.0.0':

dependencies { 
     classpath 'com.google.gms:google-services:3.0.0'
     classpath 'com.android.tools.build:gradle:2.2.3'...
}

In the app level build.gradle, add dependency: compile 'com.google.android.gms:play-services:10.0.1'

dependencies { 
... 
    compile 'com.google.android.gms:play-services:10.0.1' 
    compile 'com.google.firebase:firebase-ads:10.0.1'
}

After that, click on the Sync link on the top right corner to synchronize Gradle.


No comments:

 
Get This <