App force关闭添加admob webview

问题描述:

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

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> 

谁能告诉我什么,我做错了什么?

+0

请从logcat的 – bart

+0

http://*.com/questions/4653763/android-admob-adview-force-close – Android

+0

http://code.google.com/mobile/afma_ads/docs/添加堆栈跟踪android/doubleclick/ – Android

您不必为了显示Admob而采取Web视图。 只需从您的xml文件中移除web浏览器,然后运行您的应用程序,它将work.else在独立的布局标记中提供该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"/> 
+0

实际上我使用的是webvie w为其他东西(这是我的应用程序) – Arveen

+0

LOGCAT E/AndroidRuntime(25559):java.lang.RuntimeException:无法启动活动Co mponentInfo {com.arv.mediafire/com.arv.mediafire.MediafireActivity}:android .view .InflateException:二进制XML文件行#12:错误充气类com.admob.and roid.ads.AdView – Arveen