App force closes on adding admob webview
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"/>
精彩评论