App force在添加admob webview时关闭

时间:2011-06-22 09:21:37

标签: android crash webview admob

我的应用程序中有一个webview,就是这样。我测试了它,它的工作但是当我在代码中添加admob时,它开始强制关闭。我做了一些评论,看看是什么导致它关闭,当我从main.xml中删除Abmob相关代码时,它开始正常工作。

main.xml中

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" >


<WebView
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="800dp" />

 <com.admob.android.ads.AdView 
    android:id="@+id/ad"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    ads:adUnitId="a14d--mypub--id--"
    ads:adSize="BANNER"
    ads:loadAdOnCreate="true"/>  />

</RelativeLayout>

任何人都可以告诉我我做错了吗?

1 个答案:

答案 0 :(得分:0)

您无需使用网页视图来显示Admob。 只需从您的xml文件中删除web iew然后运行您的应用程序,它就会工作。请在单独的布局标记中提供Admob代码。

<com.admob.android.ads.AdView 
xmlns:ads="http://schemas.android.com/apk/res/**Prove Your Package name,e.g. com.xyz.abc**"
    android:id="@+id/ad"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    ads:adUnitId="a14d--mypub--id--"
    ads:adSize="BANNER"
    ads:loadAdOnCreate="true"/>
相关问题