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 = ""
            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>

Dani AI

Generated

The stack trace posted by shows a runtime error caused by a missing class: Didn't find class "com.google.ads.AdView". That exact failure means the layout is trying to inflate the old, standalone AdMob view but that class is not packaged in the APK (either the legacy AdMob jar is missing or you mixed old XML/classes with Google Play services). 's pointer to the AdMob docs is useful — Google moved AdMob into Play services and migration is the recommended path. (example report of the missing-class crash).

Fix in practice: use the Google Mobile Ads view and include the correct SDK (do not rely on the old com.google.ads.* classes). In XML use the Play services AdView and the res-auto namespace, and include the Play Services Ads dependency (or import the google-play-services_lib in Eclipse). Also ensure the modern requirement to declare your AdMob App ID in the manifest (missing it can crash at startup). Example (replace AD_UNIT / APP_ID with your test/real IDs):

<com.google.android.gms.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    ads:adSize="BANNER"
    ads:adUnitId="ca-app-pub-XXX/YYY" />

See Google’s AdView guidance and notes on the XML namespace, and the manifest App ID requirement. (AdView docs, XML namespace note, manifest App ID crash note).

Eclipse-specific checklist: import the google-play-services_lib project into your workspace and reference it (adding only the JAR often causes problems or missing resources), remove duplicate AdMob/Play-services jars, check Order & Export, then Project → Clean. If problems persist, inspect the built APK to confirm the Play services classes are present. (import advice and common fixes, jar-mismatch/cleanup notes).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.