2015-02-05 87 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

相关问题