2017-11-18 51 views
0

我剛剛接觸android.currently我正在使用eclipse與android 4.0 api 14.Before整合admob所有作品well.after整合admob後顯示一個錯誤 「找不到屬性adsize資源標識符」和「在main.xml中找不到屬性adUnitId的資源標識符」在我的應用程序中集成Admob

我發現了許多類似的問題,但無法解決它。

我的main.xml文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/RootLayout" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<LinearLayout 
     android:id="@+id/adLayout" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:orientation="vertical" > 
    <com.google.android.gms.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     ads:adSize="BANNER" 
     ads:adUnitId="@string/admob_publisher_id"/> 
     </LinearLayout> 
     </RelativeLayout> 

主要activity.java

import com.google.android.gms.ads.*; 

    AdView adView = (AdView)this.findViewById(R.id.adView); 
    AdRequest adRequest = new AdRequest.Builder().build(); 
    adView.loadAd(adRequest); 

清單文件

<?xml version="1.0" encoding="utf-8"?> 
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.easywebapp" 
android:installLocation="auto" 
android:versionCode="1" 
android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="11" 
    android:targetSdkVersion="18" /> 

<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 


<application 
    android:allowBackup="true" 
    android:hardwareAccelerated="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" > 
    <meta-data android:name="com.google.android.gms.version" 
    android:value="@integer/google_play_services_version" /> 
    <activity 
     android:name="com.example.asd.Splashscreen" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 

    <activity 
     android:name="com.example.asd.Image" 
     android:label="@string/title_activity_image" > 
    </activity> 
    <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> 

回答

0

代碼似乎是谷歌fine.Check玩,如果包括驗證其路徑包括服務庫。

0

嘗試以下鏈接 refer here

<com.google.android.gms.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     ads:adSize="BANNER" 
     ads:adUnitId="@string/banner_home_footer"> 
    </com.google.android.gms.ads.AdView> 
0

在gradle這個文件中添加此

compile 'com.google.android.gms:play-services-ads:10.2.0' 
相關問題