2014-05-15 127 views
0

我使用谷歌玩服務的lib,這是我的主要 XMLAdMob來6.4.1 dosnt工作

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

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

</LinearLayout> 

,這是我的清單(不知道在那裏的狗屎真的good..did很多)

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="me.noamro.bloo" 
    android:versionCode="1" 
    android:versionName="1.0" > 

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

    <application 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" > 
      <meta-data android:name="com.google.android.gms.version" 
       android:value="@integer/google_play_services_version"/> 
     <activity 
      android:name=".MainActivity" 
      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.google.android.gms.ads.AdActivity" 
      android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/> 
    </application> 

</manifest> 
在main.xml中的圖形佈局,我可以看到紅色的框,說

「必需的XML屬性‘adSize時’失蹤」 ,我並設置adSize時... 我只是想,當我的遊戲作品在菜單狀態中會有一個廣告。 請幫助

+0

您是否添加了Java的東西來加載廣告? –

回答

0

我會改變

ads:adSize="BANNER" 

TO

ads:adSize="SMART_BANNER" 

否則廣告取決於屏幕尺寸不會調整(除非這就是你想要的東西),並在該onCreate方法你java文件加入:

adView = new AdView(this); 
     AdView adView = (AdView) this.findViewById(R.id.adView); 
     AdRequest adRequest = new AdRequest.Builder() 
     //.addTestDevice("") - You'll find your device ID in the LogCat output starting with a # it is recommended that you have a test device but it's up to you 
     .build(); 
     adView.loadAd(adRequest);