Ok, back to AdMobs.
Sometimes it's not so obvious than it looks like especillay when you're tired.
So for AdMobs, first download the Jar here :
https://developers.google.com/mobile-ads-sdk/download
Then unzip it (beside to your Android SDK is a good idea).
Then include it into your project:
1) Include the jar within your project properly
Copy paste the jar within your project (create a lib folder and paste it there)
Open your Build Path and:
- First add the Jar to your librairies (use the "Add Jar" button and choose the one in your \lib folder)
- Second, add the lib folder as a Source of your project
->Either an build error (the class can't be found)
->Either a run Time error (the class can't be found, the exact sentence looks like: ERROR/AndroidRuntime(2339): Caused by: java.lang.ClassNotFoundException: com.admob.ads.AdView in loader dalvik.system.PathClassLoader@ )
2)When adding to a layout.xml take care about the xmlns:ads.
In fact the parent container of your adMobs banner must declare the namespace of your adMobs.
So insure that the layout container is the following:
LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
If your don't do that you'll have an error in your layout/main.xml when trying to build your project that looks like the ads:adSize is missing...
3)And at least in your Manifest if you have an error when pasting the
try to open your project.properties and target at least
# Project target.
target=android-13
I defines which SDK to use to compile.
But it not seems to me a good idea. If any one understand that, please tell me. I don't want to change my compilation just because of a lib...
Now it should works...
In your build path:
So, Thanks who?
Thanks, Android2ee, the Android Programming Ebooks :o)
Mathias Séguy
mathias.seguy.it@gmail.com
Auteur Android2EE
Ebooks to learn Android Programming.
Meet me on Google+
Follow me on Twitter
Join my LinkedIn network ou Viadeo
2)When adding to a layout.xml take care about the xmlns:ads.
In fact the parent container of your adMobs banner must declare the namespace of your adMobs.
So insure that the layout container is the following:
LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
If your don't do that you'll have an error in your layout/main.xml when trying to build your project that looks like the ads:adSize is missing...
3)And at least in your Manifest if you have an error when pasting the
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
try to open your project.properties and target at least
# Project target.
target=android-13
I defines which SDK to use to compile.
But it not seems to me a good idea. If any one understand that, please tell me. I don't want to change my compilation just because of a lib...
Now it should works...
In your build path:
So, Thanks who?
Thanks, Android2ee, the Android Programming Ebooks :o)
Mathias Séguy
mathias.seguy.it@gmail.com
Auteur Android2EE
Ebooks to learn Android Programming.
Meet me on Google+
Follow me on Twitter
Join my LinkedIn network ou Viadeo
No comments:
Post a Comment