Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,768,220 Members 45,078 Now Online
XDA Developers Android and Mobile Development Forum

AdMob Issues - Logcat

Tip us?
 
coolbud012
Old
(Last edited by coolbud012; 19th May 2014 at 01:58 PM.)
#1  
coolbud012's Avatar
Senior Member - OP
Thanks Meter 24
Posts: 202
Join Date: Sep 2012
Location: Bangalore
Default AdMob Issues - Logcat

Hello Frieds,

Today while I tried to integrate Admob in my app...

Im Facing this error while running the app in Emulator.

http://pastebin.com/Tbg06tdR

This is the code that I have put up in my XML.

Code:
<com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_alignParentBottom="true"
        android:layout_below="@+id/gridView"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        ads:adUnitId="a155465208dx522s"
	ads:adSize="BANNER"
        ads:loadAdOnCreate="true"
         />

Aptitude Cracker - An Application for all Competitive Exams and all In One Aptitude Preparation
---------------------------------------------------------------------------------------------------------------------------------
DroidAcid - Get all android tutorials and Micromax CanvasHD A116 guides.
 
CrotaNexus
Old
#2  
CrotaNexus's Avatar
Senior Member
Thanks Meter 267
Posts: 206
Join Date: May 2013
Location: Rome

 
DONATE TO ME
You have an error at line 27. Want a hint? For integrate AdMob into your Android application follow this method:
  1. Into your layout insert
Code:
	<LinearLayout  
   		android:id="@+id/ads"
   		android:orientation="vertical"
   		android:layout_width="match_parent"
   		android:layout_height="wrap_content"
   		android:layout_alignParentBottom="true" 
   		android:gravity="bottom"/>
  1. Into your Activity insert
Code:
AdView adView = new AdView(this, AdSize.BANNER, "your_id");
LinearLayout layout = (LinearLayout)findViewById(R.id.ads);
layout.addView(adView);
adView.loadAd(new AdRequest());
This is a very quickly and efficient way to integrate AdMob.
+ Kernel Manager Developer +

Download my Android applications from HERE
I won't be a rockstar. I will be a legend
 
coolbud012
Old
#3  
coolbud012's Avatar
Senior Member - OP
Thanks Meter 24
Posts: 202
Join Date: Sep 2012
Location: Bangalore
Quote:
Originally Posted by CrotaNexus View Post
You have an error at line 27. Want a hint? For integrate AdMob into your Android application follow this method:
  1. Into your layout insert
Code:
	<LinearLayout  
   		android:id="@+id/ads"
   		android:orientation="vertical"
   		android:layout_width="match_parent"
   		android:layout_height="wrap_content"
   		android:layout_alignParentBottom="true" 
   		android:gravity="bottom"/>
  1. Into your Activity insert
Code:
AdView adView = new AdView(this, AdSize.BANNER, "your_id");
LinearLayout layout = (LinearLayout)findViewById(R.id.ads);
layout.addView(adView);
adView.loadAd(new AdRequest());
This is a very quickly and efficient way to integrate AdMob.
Thanks that worked...Actually the main issue was that the SDK was not properly getting integrated in the app.

Solution
Quote:
Go to Project Properties :
Then Built Path : Order and Export and select AdMob SDK there...
But I will be going Java way only. Just 1 thing any suggestion for using this for every layout as I dont want to create the Layout in every xml file as well as repeating the code in every java file too.

Aptitude Cracker - An Application for all Competitive Exams and all In One Aptitude Preparation
---------------------------------------------------------------------------------------------------------------------------------
DroidAcid - Get all android tutorials and Micromax CanvasHD A116 guides.
 
CrotaNexus
Old
#4  
CrotaNexus's Avatar
Senior Member
Thanks Meter 267
Posts: 206
Join Date: May 2013
Location: Rome

 
DONATE TO ME
Quote:
Originally Posted by coolbud012 View Post
Just 1 thing any suggestion for using this for every layout as I dont want to create the Layout in every xml file as well as repeating the code in every java file too.
I have never tried but you can make a layout that has the LinearLayout inside and after, into the desidered layout, include it with include tag. For the Java code, instead, you can try to do a method and pass the LinearLayout. I don't know if these solutions work. Try yourself.
+ Kernel Manager Developer +

Download my Android applications from HERE
I won't be a rockstar. I will be a legend
 
coolbud012
Old
#5  
coolbud012's Avatar
Senior Member - OP
Thanks Meter 24
Posts: 202
Join Date: Sep 2012
Location: Bangalore
Quote:
Originally Posted by CrotaNexus View Post
I have never tried but you can make a layout that has the LinearLayout inside and after, into the desidered layout, include it with include tag. For the Java code, instead, you can try to do a method and pass the LinearLayout. I don't know if these solutions work. Try yourself.
I know about include..Trying to figure it out what should I do exactly...
BTW thanks

Aptitude Cracker - An Application for all Competitive Exams and all In One Aptitude Preparation
---------------------------------------------------------------------------------------------------------------------------------
DroidAcid - Get all android tutorials and Micromax CanvasHD A116 guides.
 
SimplicityApks
Old
#6  
SimplicityApks's Avatar
Senior Member
Thanks Meter 321
Posts: 306
Join Date: May 2013
Location: Aachen
Quote:
Originally Posted by coolbud012 View Post
I know about include..Trying to figure it out what should I do exactly...
BTW thanks
Make a custom view which extends LinearLayout ( or maybe FrameLayout would be better?) And have it create the adview as child with id and stuff you need. Then you just need to copy paste the XML tag into every layout file.
The Following User Says Thank You to SimplicityApks For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes