chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
11/10/12 11:23 PM (13 years ago)

how to config admob on android/eclipse

I'm new to admob, so naturally I'm having issues getting it up and running. I downloaded the latest admob sdk and added it to my project. Then I added in the necessary lines in the manifest file. However, I'm getting the following error: error: Error: String types not allowed (at 'configChanges' with value 'keyboard| keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize'). I'm doing this on a BT 2.0 app with the Google API 8 (Android 2.2). Thanks, Chris http://www.churchphoneapps.com
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
11/11/12 05:44 AM (13 years ago)
You are getting that error coz admob sdk needs to compile the project on Google API Level 13. There is one simple tutorial by Nishad to integrate admob in the layout file. Even i prefer to include admob in the layout file instead of adding it in the class files. Steps: Step 1. Download the Admob sdk then In eclipse, right click on the project name and select Properties. Select Java Build Path on the left and then make sure the Libraries tab is selected at the top. Then click Add External JARS... on the right side of the window. Navigate to where you saved the unzipped AdMob sdk and select the .jar file. Step 2. Added These two Line in AndroidManifest.xml before the closing application tag ..................................................... <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/> ..................................................... Step 3. Modify your screen_menulist.xml ..................................................... <com.google.ads.AdView android:layout_height="wrap_content" android:id="@+id/adView" android:layout_width="wrap_content" ads:adUnitId="Your ADD MOB ID" ads:adSize="BANNER" ads:loadAdOnCreate="true" android:layout_alignParentBottom="true"> </com.google.ads.AdView> </RelativeLayout> .................................................... Note :- Don't Forget to Add xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" After <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" .................................................... My :- screen_customhtml.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:id="@+id/containerView" android:background="@android:color/transparent" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:id="@+id/subContainer" android:layout_height="fill_parent" android:layout_width="fill_parent" android:gravity="center_horizontal" android:orientation="vertical"> <com.google.ads.AdView android:layout_height="wrap_content" android:id="@+id/adView" android:layout_width="wrap_content" ads:adUnitId="Your ADD MOB ID" ads:adSize="BANNER" ads:loadAdOnCreate="true" android:layout_alignParentBottom="true"> </com.google.ads.AdView> <WebView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/webView" android:layout_width="fill_parent" android:layout_height="fill_parent"> </WebView> </LinearLayout> <com.google.ads.AdView android:layout_height="wrap_content" android:id="@+id/adView" android:layout_width="wrap_content" ads:adUnitId="Your ADD MOB ID" ads:adSize="BANNER" ads:loadAdOnCreate="true" android:layout_alignParentBottom="true"> </com.google.ads.AdView> </RelativeLayout> Link: http://www.buzztouch.com/forum/thread.php?tid=16591ACFB8928734B2F628C&command=isSearching&currentPage=1&topicTitle=admob&createdBy=&repliedBy=&minViews=-1&maxViews=-1&minReplies=-1&maxReplies=-1&forumCategory=
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
11/11/12 05:47 AM (13 years ago)
ONe more step i forgot to mention- After adding the build path to the sdk, again right click the project file and select properties---> android--- and select Google API 13. If you dont have Google API Level 13, then you will have to download it.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
11/14/12 10:10 AM (13 years ago)
Thanks - I just got around to this - your instructions worked great (once I figured out where the xml files were!) :) Thanks again
 
nelaye
Android Fan
Profile
Posts: 95
Reg: Jan 29, 2013
Kuantan
2,500
like
06/07/13 11:37 AM (12 years ago)
Hi Sandeep, I follow yuor step and getting warning at bt_activty_root.Can I just ignore?
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
06/07/13 12:04 PM (12 years ago)
@nelaye, you can ignore all warnings it they are just warnings so far. But if its an error then you need to check whats causing it. Tell me if i can do any thing else for you.
 
nelaye
Android Fan
Profile
Posts: 95
Reg: Jan 29, 2013
Kuantan
2,500
like
06/08/13 08:57 PM (12 years ago)
ooh. OK. it just warning thanks sandeep
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
06/10/13 08:09 AM (12 years ago)
Usually you can ignore warnings - sometimes they are important! But if it's in the BT_activity_root.java file, it's almost certainly safe to ignore.
 
nelaye
Android Fan
Profile
Posts: 95
Reg: Jan 29, 2013
Kuantan
2,500
like
06/10/13 06:44 PM (12 years ago)
Thanks Chris
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
06/10/13 07:27 PM (12 years ago)
no problem - or rather, if you have problems, let us know! :)
 
mickeywong
Aspiring developer
Profile
Posts: 35
Reg: Jan 10, 2013
Kuala Lumpur
8,800
like
06/24/13 10:36 AM (12 years ago)
Hi everyone, I tried to incorporate the admob code for my android project as shown by nishad and Sandeep but still i got errors (the main error - error:Error parsing XML: not well-formed(invalid token) on line 19) <?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:id="@+id/containerView" android:background="@android:color/transparent" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:id="@+id/subContainer" android:layout_height="fill_parent" android:layout_width="fill_parent" android:gravity="center_horizontal" android:orientation="vertical"> <com.google.ads.AdView android:layout_height="wrap_content" android:id="@+id/adView" android:layout_width="wrap_content" ads:adUnitId="a151c84ab196555" ads:adSize="BANNER" android:layout_alignParentBottom="true"> ads:loadAdOnCreate="true" > android:layout_alignParentBottom="true"> </com.google.ads.AdView> <WebView android:id="@+id/webView" android:layout_width="fill_parent" android:layout_height="fill_parent"> </WebView> </LinearLayout> <com.google.ads.AdView android:layout_height="wrap_content" android:id="@+id/adView" android:layout_width="wrap_content" ads:adUnitId=""a151c84ab196555"" ads:adSize="BANNER" ads:loadAdOnCreate="true" android:layout_alignParentBottom="true"> </com.google.ads.AdView> </RelativeLayout> Can Nishad and Sandeep assist or anyone else here gone through the same problem? Thanks Mickey
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
06/24/13 12:00 PM (12 years ago)
Did you check what the line number 19 was? You got the xml parsing error because of the line no 19. I guess it is the following line of code- android:layout_alignParentBottom="true" Well you actually have to remove this line. But instead of removing this line i would like that you remove all the ad layout from the upper screen (above the webview). Because new admob policy makes it impermissible to have 2 banner ads on a single layout. So remove all the admob code above the webview.
 
mickeywong
Aspiring developer
Profile
Posts: 35
Reg: Jan 10, 2013
Kuala Lumpur
8,800
like
06/25/13 04:37 AM (12 years ago)
Thanks @Sandeep . You are a genius! Just removing the line , save, clean and build and voila! Thanks once again!
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
06/25/13 06:24 AM (12 years ago)
Nice to know it worked for you. :)
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.