Reputation: 2600
I am trying to add interstitial ads into my android application but I got the below error message:
java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 7895000 but found 7571000. You must have the following declaration within the element:
I tried adding the code to my AndroidManifest, but it didn't provide any solutions. Anyone have an idea?
Manifest Code:
<meta-data
android:name="com.google.android.gms.version"
android:value="7895000 " />
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
Upvotes: 0
Views: 490
Reputation: 1517
This happens because the meta-tag you are using is old. Answer is simple -
In Android Manifest, inside <application>
, replace this -
<meta-data android:name="com.google.android.gms.version" android:value="7571000" />
With this -
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
In Gradle(If using Android Studio), put this -
compile 'com.google.android.gms:play-services-ads:7.8.0'
compile 'com.google.android.gms:play-services-base:7.8.0'
NOTE - Put a +
sign if this doesn't work like this -ads:7.8.+
and base:7.8.+
but is not very well as there are some issues with this.
If the problem still exists, try this. (Though I don't recommend it), use this -
<meta-data android:name="com.google.android.gms.version" android:value="7895000" />
If you like this answer, please mark it as selected
.
EDIT - I made an app with apps just a few days ago, used this code and it works fine -
Manifest -
<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.sampleapp.app">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme">
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<!-- EXTRA CODE -->
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" />
</application>
</manifest>
Gradle -
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.sampleapp.app"
minSdkVersion 10
targetSdkVersion 22
versionCode 2
versionName "1.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.google.android.gms:play-services:7.5.0' //LOOK HERE
}
LATEST EDIT - I think the Admob/Google Play Services library you are using is old. Try updating it.
Upvotes: 2
Reputation: 940
It's about incorrect Google Play services version. Firsto of all add:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
to the application block. Secondly make sure that in the gradle config you are using specific Google Play Services version like:
compile 'com.google.android.gms:play-services-ads:7.8.0'
compile 'com.google.android.gms:play-services-base:7.8.0'
Avoid using "+" like:
compile 'com.google.android.gms:play-services-ads:7.+'
Because you may include library that is not supported at the moment.
Upvotes: 0