2011-06-23 227 views
0

我今天做了一些更新到我的应用程序,但现在admob不工作的权利,它给了我一个错误广告说adview missing xml attribute "adsize"。现在改变我做了什么都没有做的广告,他们一直是相同的,因为我实现了他们的工作奇怪admob问题

这是我的XML

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/res/com.notify.me.lite" 
android:layout_width="fill_parent" 
android:id="@+id/mainLayout1" 
android:layout_height="fill_parent" android:orientation="vertical"> 
      <com.google.ads.AdView android:id="@+id/adView" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        ads:adUnitId="id" 
        ads:adSize="BANNER"/> 
    <WebView android:layout_width="fill_parent" android:id="@+id/webView1" android:layout_height="fill_parent"></WebView> 

</LinearLayout> 

并在其实施

public class Main extends Activity { 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main_webview); 

    WebView browser = (WebView) findViewById(R.id.webView1); 
    browser.loadUrl("file:///android_asset/about.html"); 
    AdView adView = (AdView)this.findViewById(R.id.adView); 
    AdRequest request = new AdRequest(); 
    request.setTesting(true); 
    adView.loadAd(request); 
} 

正如你可以看到在XML文件中有adsize,所以应该没有理由为什么我应该得到这个错误。关于为什么突然发生这种想法?

回答

0

不知道为什么它突然采空工作,但每当我使用AdMob,我总是把它放在一个单独的布局,XML,如:

<RelativeLayout android:id="@+id/rLayAdMob" 
     android:layout_width="match_parent" android:layout_height="50dip"> 
</RelativeLayout> 

然后在OnCreate函数我建立AdView的,如:

adView = new AdView(Menu.this, AdSize.BANNER, MY_AD_UNIT_ID); 
RelativeLayout layout = (RelativeLayout)findViewById(R.id.rLayAdMob); 
layout.addView(adView); 

我从来没有这样做过任何问题,只需要对代码进行一些小改动。

希望这有助于

肯尼

+0

我切换到你的方法,它再次炒作虽然我仍然困惑,为什么我的工作不再工作 – tyczj

1

谷歌更新了AdMob的库,但并没有记录必须的变化,按照这个论坛thread

变化的实质是更新广告命名空间:

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
+0

感谢你非常matyjas! – Aracem