using: eclipse
I have created a android app and I am trying to add some ads on to it. I am using admob.com but I am not sure what I am doing wrong. First here is error I am getting:
-------
ERROR:
-------
08-27 23:09:03.650: E/AndroidRuntime(26340): FATAL EXCEPTION: main
08-27 23:09:03.650: E/AndroidRuntime(26340): Process: com.g.tictactoe, PID: 26340
08-27 23:09:03.650: E/AndroidRuntime(26340): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.g.tictactoe/com.gemini.bh.Splash}: android.view.InflateException: Binary XML file line #7: Error inflating class com.google.ads.AdView
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2328)
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.app.ActivityThread.access$900(ActivityThread.java:169)
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.os.Handler.dispatchMessage(Handler.java:102)
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.os.Looper.loop(Looper.java:136)
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.app.ActivityThread.main(ActivityThread.java:5476)
08-27 23:09:03.650: E/AndroidRuntime(26340): at java.lang.reflect.Method.invokeNative(Native Method)
08-27 23:09:03.650: E/AndroidRuntime(26340): at java.lang.reflect.Method.invoke(Method.java:515)
08-27 23:09:03.650: E/AndroidRuntime(26340): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
08-27 23:09:03.650: E/AndroidRuntime(26340): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
08-27 23:09:03.650: E/AndroidRuntime(26340): at dalvik.system.NativeStart.main(Native Method)
08-27 23:09:03.650: E/AndroidRuntime(26340): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.google.ads.AdView
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
08-27 23:09:03.650: E/AndroidRuntime(26340): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:366)
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.app.Activity.setContentView(Activity.java:2031)
08-27 23:09:03.650: E/AndroidRuntime(26340): at com.g.bh.Splash.onCreate(Splash.java:19)
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.app.Activity.performCreate(Activity.java:5451)
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
08-27 23:09:03.650: E/AndroidRuntime(26340): ... 11 more
08-27 23:09:03.650: E/AndroidRuntime(26340): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.ads.AdView" on path: DexPathList[[zip file "/data/app/com.g.tictactoe-15.apk"],nativeLibraryDirectories=[/data/app-lib/com.gemini.g-15, /vendor/lib, /system/lib]]
08-27 23:09:03.650: E/AndroidRuntime(26340): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
08-27 23:09:03.650: E/AndroidRuntime(26340): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
08-27 23:09:03.650: E/AndroidRuntime(26340): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.view.LayoutInflater.createView(LayoutInflater.java:565)
08-27 23:09:03.650: E/AndroidRuntime(26340): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
08-27 23:09:03.650: E/AndroidRuntime(26340): ... 21 more
1st thing I did was downloaded "google Play Services for Froyo" from my eclipse android sdk manager. Than I added "google-play-services.jar" in to "Referenced Libraries" in eclipse project.
#------------------------------------------------------
# 2nd thing I did was to add ad on my layout xml file
# res > layout > mainXmlFile
#-------------------------------------------------------
<com.google.ads.AdView
xmlns:ads = "http://schemas.android.com/apk/lib/com.google.ads"
android:id = "@+id/adView"
android:layout_width = "fill_parent"
android:layout_height = "wrap_content"
ads:adUnitId = "ci-apa-pab-44_myKey"
ads:adSize = "BANNER"
ads:testDevices = "TEST_EMULATOR, "
ads:loadAdOnCreate = "true" />
#------------------------------------------
# Lastly I add permission in manifest file
#AndroidManifest
#-------------------------------------------
.......
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>