VSB VSB - 3 months ago 63
Android Question

importing google play services to android project failed

I'm trying to add AdMob to my application. I followed instructions listed here, but it will lead to error which below imports are failed and

cannot be resolved:

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

Here is my root gradle file:

buildscript {
repositories {
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// ...
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 here is my app .gradle file:

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

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


I think that you forgot to include admob dependency :

compile 'com.google.firebase:firebase-ads:9.4.0'

a core package is just analytics as stated here : https://firebase.google.com/docs/android/setup#available_libraries