I want to add admob to my project and have followed the instructions from the documentation but I'm getting an error:
Cannot find symbol '@integer/google_play_services_version
inside the AndroidManifest.xml
. I've looked inside the sdk directory and google_play_services version 4.0.30 is installed. Here's my build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
runProguard true
proguardFile getDefaultProguardFile('proguard-android.txt')
}
}
productFlavors {
defaultFlavor {
proguardFile 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/libGoogleAnalyticsServices.jar')
compile 'com.google.android.gms:play-services:4.0.30'
}
After adding it, I've synced the project with gradle. I also have the required entry in AndroidManifest.xml
which gives me the error
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
The official docs say that for android studio we don't need to include the library but I don't understand why it doesn't find it.
Edit: I finally solved it. The problem was that I was using the wrong sdk. Android studio ships with its own SDK and that was set as default in the IDE.
To fix
- Change your project's SDK from
android-studio\\sdk
toandroid-sdk
. If you don't know how, here's how. - If you get an error about build tools not found make sure the version in your
build.gradle
corresponds to your new sdk's version.