2015-02-05 141 views
0

我使用這個代碼:在應用程序中添加廣告?

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

不過是錯誤的:

Description Resource Path Location Type error: No resource identifier 
    found for attribute 'loadAdOnCreate' in package 'com.teste.teste1' 
    activity_teste.xml /Teste/res/layout line 120 Android AAPT Problem 

回答

0

您需要添加獨特的廣告單元ID。爲了獲得此功能,您需要在設置新的應用獲利應用後,在AdMob配置文件中創建新的橫幅廣告。

編輯: 刪除第120行的「loadAdOnCreate」屬性,因爲它不能用作XML屬性。

編輯2: 可能的新的解決方案:

  • 添加xmlns:ads="http://schemas.android.com/apk/res-auto您parentl ayout XML格式。

  • 加入谷歌Play服務的依賴關係:

編譯 'com.google.android.gms:發揮服務:6 +'

  • 添加中間標籤:
<!--This meta-data tag is required to use Google Play Services.--> 
    <meta-data android:name="com.google.android.gms.version" 
      android:value="@integer/google_play_services_version" /> 
  • 添加配置的變化和主題adactivity在應用程序的清單:
<!--Include the AdActivity configChanges and theme. --> 
    <activity android:name="com.google.android.gms.ads.AdActivity" 
     android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" 
     android:theme="@android:style/Theme.Translucent" /> 
+0

是的,我創建帳戶並tnho ID。 – Rodolfo 2015-02-05 23:05:09

+0

@Rodolfo檢查我的編輯 – domi 2015-02-05 23:08:38

+0

以及刪除錯誤,但沒有顯示橫幅 – Rodolfo 2015-02-05 23:28:55

相關問題