添加编译 "com.google.android.gms:play-services:3.1.+" 后立即在包中找不到属性 'adSize' 的资源标识符

Getting No resource identifier found for attribute 'adSize' in package right after adding compile "com.google.android.gms:play-services:3.1.+"

我得到

No resource identifier found for attribute 'adSize' in package

No resource identifier found for attribute 'adUnitId' in package

错误,因为我更新了 build.gradle 文件。

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.admobdemo"
        minSdkVersion 11
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    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.0.0'
    compile "com.google.android.gms:play-services:3.1.+"

    compile project(path: ':backend', configuration: 'android-endpoints')
}

如果我替换

compile "com.google.android.gms:play-services:3.1.+"

compile 'com.google.android.gms:play-services:7.0.0'

它 work.But 我也在应用程序中实现 GCM 推送通知。根据 google docs 我必须添加 google-play-service:3.1.+。

My_Activity.xml

<android.support.v4.widget.DrawerLayout xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<!-- The main content view -->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_margin="0dp"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"

    android:background="@color/dark_brown"
    android:orientation="vertical"
    tools:context=".GeneralInstructionsActivity" >

    <WebView
        android:id="@+id/webView1"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="2"
        />

    <Button
        android:id="@+id/otherAppsBtn"
        style="@style/ButtonStyle"
        android:visibility="gone"
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:padding="3dp"
        android:layout_gravity="center"
        android:layout_margin="3dp"
        android:gravity="center"
        android:onClick="showOtherApps"
        android:text="@string/otherApps"
        android:textSize="17sp"
        android:typeface="serif" />

    <!-- <com.google.android.gms.ads.AdView
         android:id="@+id/about_adView"
         android:background="@android:color/background_dark"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         ads:adUnitId="@string/ad_unit_id"
         ads:adSize="SMART_BANNER"
         />-->
    <com.google.android.gms.ads.AdView
        android:id="@+id/about_adView1"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="@string/ad_unit_id" >
    </com.google.android.gms.ads.AdView>

</LinearLayout>


<!-- The navigation drawer -->

<LinearLayout
    android:id="@+id/drawer"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="#f4f4f4"
    android:orientation="vertical" >

    <ExpandableListView
        android:id="@+id/drawer_list1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/dark_brown"
        android:cacheColorHint="#00000000"
        android:divider="#666666"
        android:dividerHeight="2dp"
        android:groupIndicator="@android:color/transparent" />
</LinearLayout>

任何帮助将不胜感激!

谢谢。

我想您会发现 Admob 是 Google Play Services 3.1 的一部分。试试更新的版本。

它绝对是 GPS 6.5 的一部分