-1

I have downloaded Google play service in SDK manager. Did everything according to their tutorial, but it's not working.

I have tried different things, but could not managed to get it working. Try even importing libary into lib folder. I am using Android Studio. What am I doing wrong?

Here is gradle code:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.r.ugani"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.google.android.gms:play-services:6.5.87'
}

Here is where I import lib.: http://i61.tinypic.com/hs80gz.png

package com.example.r.ugani;

import android.app.ListActivity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import java.util.Arrays;
import java.util.List;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.AdRequest;





public class Results extends ListActivity  {

    private InterstitialAd interstitial;

...

        // Create the interstitial.
        interstitial = new InterstitialAd(this);
        interstitial.setAdUnitId("ca-app-pub-97868....1309753");

        // Create ad request.
        AdRequest adRequest = new AdRequest.Builder().build();

        // Begin loading your interstitial.
        interstitial.loadAd(adRequest);


    }

//     Invoke displayInterstitial() when you are ready to display an interstitial.
    public void displayInterstitial() {
        if (interstitial.isLoaded()) {
            interstitial.show();
        }
    }
Everlastinf
  • 33
  • 1
  • 1
  • 5
  • Did you get any errors at compile time or the interstitial is not showing? – Vigneshwaran Murugesan Feb 27 '15 at 11:08
  • No, no errors when compiling, but when activity, where interstitial should have been showed, is started, I get this error and ad is not showing: "Could not find com.google.ads.AdActivity, please make sure it is declared in AndroidManifest.xml". This is in my manifest: http://i59.tinypic.com/29f7a6r.png – Everlastinf Feb 27 '15 at 11:21
  • Here is my code again: http://i61.tinypic.com/hs80gz.png – Everlastinf Feb 27 '15 at 11:27
  • http://pastebin.com/0221suGL @Vigneshearan.m Activity where ad should be shown is called com.example.r.ugani.Results. – Everlastinf Feb 27 '15 at 11:38
  • You have to add the Adactivity in your Manifest this post may help you http://stackoverflow.com/questions/8860284/could-not-find-com-google-ads-adactivity – Vigneshwaran Murugesan Feb 27 '15 at 11:42

2 Answers2

0

Your issue is with this line:

compile 'com.google.android.gms:play-services:6.5.87'

I personally use this for now

compile 'com.google.android.gms:play-services:6.1.+'

I cannot remember the exact reasoning for this but it fixed it for me! If I remember the reason i will edit this post.

apmartin1991
  • 3,064
  • 1
  • 23
  • 44
0

Did you try Clean project option?

Then you can try this solution Android Studio with Google Play Services

Community
  • 1
  • 1
DoubleK
  • 542
  • 3
  • 16