开发者

App force closes on adding admob webview

开发者 https://www.devze.com 2023-03-15 01:40 出处:网络
I have a webview in my app, that\'s it. I tested it, its working but when i add admob to the code, it start开发者_JS百科s force closing. I did some commenting to see what\'s causing it to close and wh

I have a webview in my app, that's it. I tested it, its working but when i add admob to the code, it start开发者_JS百科s force closing. I did some commenting to see what's causing it to close and when i remove the Abmob related code from main.xml, it starts working normally.

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>

Can Anybody tell me what i am doing wrong?


You need not to take web view for displaying Admob. Just remove web iew from your xml file then run your application , it will work.else provide that Admob code in separate layout tag.

<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

精彩评论

暂无评论...
验证码 换一张
取 消