4

I'm trying to add ads in my app. Have been installing the latest Play Services (15) through the SDK manager, imported it in Eclipse (making sure to mark the "copy files" option as recommended), and added it as a library in my app project.

The app crashes and I'm getting the following logcat error:

The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4132500 but found 4242000. You must have the following declaration within the element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

However, I do have that exact declaraction in my AndroidManifest.xml file:

<meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

I also have:

<activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

In my activity_main.xml I have:

<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adUnitId="ca-app-pub-6017910481591555/7224650198"
        ads:adSize="BANNER" />

And in my onCreate() in my MainActivity is:

AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
    .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
    .addTestDevice("my device code") //yes, I have the correct code here
    .build();
adView.loadAd(adRequest);

and the following is imported:

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

I have found other answers where is error is very similar, only in those cases the found value was 0, not 4242000 as here.

If I change "@integer/google_play_services_version" into the expected value "4132500", I get the following error instead:

The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

I find references to both com.google.android.gms.ads.AdView at AdMob and com.google.ads.AdView in the Android lessons, and I might be mixing those up(?) What needs to be done in order to not receive these error messages?

knahrvorn
  • 71
  • 5

1 Answers1

2

it is because different version of google play service lib. Just open res/values/version.xml in your google_play_services_lib and change 4242000 to 4132500. It will work.

caolang
  • 21
  • 1
  • Thank you for your answer, but as my original post states, I already tried this with the following error as a result: "The Google Play services resources were not found. Check your project configuration to ensure that the resources are included." I think my next step will be to completely remove the SDK and Eclipse, including settings, and install from scratch. – knahrvorn Mar 21 '14 at 08:36