Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 奇怪的admob问题_Android_Admob - Fatal编程技术网

Android 奇怪的admob问题

Android 奇怪的admob问题,android,admob,Android,Admob,我今天对我的应用程序做了一些更新,但现在admob不能正常工作,它在广告中给我一个错误,说adview缺少xml属性“adsize”。现在,我所做的改变与广告无关,自从我实施这些改变并开始工作以来,它们一直是一样的 这是我的xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res/com.notify.m

我今天对我的应用程序做了一些更新,但现在admob不能正常工作,它在广告中给我一个错误,说
adview缺少xml属性“adsize”
。现在,我所做的改变与广告无关,自从我实施这些改变并开始工作以来,它们一直是一样的

这是我的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>

正如您所看到的,adsize在xml文件中,所以我没有理由会出现这个错误。关于为什么会突然发生这种情况的想法?

不知道为什么它突然停止工作,但每当我使用Admob时,我总是将它放在一个单独的布局中,使用xml,如:

<RelativeLayout android:id="@+id/rLayAdMob"
        android:layout_width="match_parent" android:layout_height="50dip">
</RelativeLayout>
这样做我从来没有遇到过任何问题,只需要对代码做一点小的修改

希望这有帮助


Kenny

根据本论坛,谷歌更新了AdMob库,但尚未记录所需的更改

更改的实质是更新ads名称空间:

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

我改用了你的方法,它又起作用了,尽管我仍然很困惑,为什么我的方法不比你的方法更有效呢!!
adView = new AdView(Menu.this, AdSize.BANNER, MY_AD_UNIT_ID);
RelativeLayout layout = (RelativeLayout)findViewById(R.id.rLayAdMob);
layout.addView(adView);
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"