How to add Ads for my android app using eclipse?

Posted by user3896367 on Stack Overflow See other posts from Stack Overflow or by user3896367
Published on 2014-08-24T16:16:02Z Indexed on 2014/08/24 16:20 UTC
Read the original article Hit count: 163

Filed under:
|
|

I am trying to add ads to my app but I don't know how I followed the instructions from this site:

https://developer.android.com/google/play-services/ads.html

I did step 1 and 2 in the getting started column, I imported the google-play-services_libs to my workspace then I referenced it in my app and I added this code in my mainfest:

<meta-data android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />

I opened the sample ad and copied this code to my xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/black"
    android:gravity="center"
    android:orientation="vertical" >

<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    ads:adUnitId="@string/ad_unit_id"/>

but I am getting this error:

The following classes could not be instantiated:
- com.google.android.gms.ads.AdView

so do you know how to fix this problem and can you tell me what should i write in the java to make in work thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about android