0

my admob code is working. page is not loading. page is getting crashed with Unfortunately stopped message please help me out.

page is not loading. page is getting crashed with Unfortunately stopped message please help me out.

   <?xml version="1.0" encoding="UTF-8"?>
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

       android:orientation="vertical"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:background="@drawable/background" 
        >
 <LinearLayout
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_above="@+id/ad_layout"
          android:layout_alignParentTop="true"           
  >        
     <TextView 
        android:id="@+id/index"

        android:layout_width="fill_parent"
        android:layout_height="30dip"
        android:textSize="20sp"

        android:layout_marginTop="60dip"
        android:gravity="center_horizontal"
        android:text= "Index" 
  />        

    <Button     android:id="@+id/thoughts"
                android:layout_height="25dip"
                android:layout_width="105dip"
                android:text="Read Thoughts"
                android:textSize="12sp"
                android:textStyle="bold"
                android:textColor="#FFFFFF"
                android:background="@drawable/button_normal"
                android:layout_marginLeft="80dip" 
                android:layout_marginTop="25dip"
                android:onClick = "vthoughts"  

                    />   

    <Button     android:id="@+id/fav"
                android:layout_height="25dip"
                android:layout_width="105dip"
                android:text="View Favorites"
                android:textSize="12sp"
                android:textStyle="bold"
                android:textColor="#FFFFFF"
                android:background="@drawable/button_normal"
                android:layout_marginLeft="80dip" 
                android:layout_marginTop="30dip"
                android:onClick = "vfav"     
                    />

    <Button     android:id="@+id/boi"
                android:layout_height="25dip"
                android:layout_width="105dip"
                android:text="Boigraphy"
                android:textSize="12sp"
                android:textStyle="bold"
                android:textColor="#FFFFFF"
                android:background="@drawable/button_normal"
                android:layout_marginLeft="80dip" 
                android:layout_marginTop="25dip"
                android:onClick = "vbio"     
                    />  
    <Button     android:id="@+id/rateapp"
                android:layout_height="25dip"
                android:layout_width="105dip"
                android:text="Rate this app"
                android:textSize="12sp"
                android:textStyle="bold"
                android:textColor="#FFFFFF"
                android:background="@drawable/button_normal"
                android:layout_marginLeft="80dip" 
                android:layout_marginTop="25dip"
                android:onClick = "rateapp"     
                    />                   

    </LinearLayout>
 <LinearLayout
         android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:gravity="bottom"
          android:layout_alignParentBottom="true"
          android:id="@+id/ad_layout"            
  >        


 <com.google.ads.AdView  xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
                     android:id="@+id/adView"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     ads:adUnitId="fsdfsdfsd"
                     ads:adSize="BANNER"
                     ads:loadAdOnCreate="true"

                     />
</LinearLayout>
</RelativeLayout>
pramod
  • 1
  • 1
  • please post the logcat – Opiatefuchs May 28 '13 at 07:58
  • java.lang.RuntimeException: Unable to start activity ComponentInfo{jharbira.thoughtsofmahatmagandhi.pramodpandey48/jharbira.thoughtsofmahatmagandhi.pramodpandey48.Start_menu}: android.view.InflateException: Binary XML file line #91: Error inflating class com.google.ads.AdView 05-28 07:23:09.554: E/AndroidRuntime(1118): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 05-28 07:23:09.554: E/AndroidRuntime(1118): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 05-28 07:23:09.554: E/AndroidRuntime(1118): – pramod May 28 '13 at 09:09

2 Answers2

0

Add xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" to your Relative layout, just before android:orientation="vertical".

Kurovsky
  • 1,081
  • 10
  • 25
0

southerton is wright, but maybe You have to remove this line from your adView. Your RelativeLayout has to be:

     <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="match_parent"
   android:layout_height="match_parent"
   android:background="@drawable/background" 
    >

and the adview:

    <com.google.ads.AdView  
                 android:id="@+id/adView"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 ads:adUnitId="fsdfsdfsd"
                 ads:adSize="BANNER"
                 ads:loadAdOnCreate="true"
                 />

Anyway, there is a mistake a few beginners make: Be sure that the folder where the AdMob Jar is inside Your Project is called "libs" and NOT "lib". Also You have to be sure, that You added the AdMob jar file to Your build path in the right way. And You have to declare the Admob inside Your Mainfest:

    <activity android:name="com.google.ads.AdActivity"
             android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

EDIT

if You got no success...reefer to this little tutorial on how to work with admob, that I posted some time ago in a similar thread:

Android app fail to start after adding admob

Community
  • 1
  • 1
Opiatefuchs
  • 9,800
  • 2
  • 36
  • 49