2011-06-22 60 views
3

我在我的應用中有一個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://stackoverflow.com/questions/4653763/android-admob-adview-force-close – Android

+0

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

回答

0

您不必爲了顯示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