android – Play服务和AdMob:预期4132500,但发现4242000

我正在尝试在我的应用中添加广告.已经通过SDK管理器安装了最新的Play服务(15),在
Eclipse中导入它(确保按照建议标记“复制文件”选项),并将其作为库添加到我的应用程序项目中.

应用程序崩溃,我收到以下logcat错误:

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” />

但是,我在AndroidManifest.xml文件中确实有这个确切的声明:

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

我也有:

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

在我的activity_main.xml中我有:

<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" />

在我的MainActivity中的onCreate()中:

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);

并导入以下内容:

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

我找到了其他答案,其中错误非常相似,只有在这些情况下,找到的值为0,而不是4242000.

如果我将“@ integer / google_play_services_version”更改为预期值“4132500”,我会收到以下错误:

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

我在AdMob找到了com.google.android.gms.ads.AdView和Android lessons中的com.google.ads.AdView的引用,我可能会把它们混合起来(?)
需要做什么才能收到这些错误消息?

最佳答案 这是因为不同版本的google play服务lib.只需在google_play_services_lib中打开res / values / version.xml,然后将4242000更改为4132500即可.

点赞