-1

I am trying to add admob features to my application. I have followed Google admob guide.
When I load the ad in the MainActivity class, I have the following error.
I attached a screenshot of the code.How to fix this issue?

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        MobileAds.initialize(getApplicationContext(), "ca-app-pub-96568545160124~214045445");
        AdView mAdView = (AdView) findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);
    }

enter image description here

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
user2020261
  • 67
  • 1
  • 1
  • 4
  • 1
    Show your gradle file.Have you added this line compile 'com.google.firebase:firebase-ads:9.8.0 – Narender Reddy Oct 27 '16 at 11:38
  • ya i added that line in to build.gradle file as a dependencies.I followed all the steps in google admob setup tutorial. – user2020261 Oct 27 '16 at 12:00
  • I assume your project is getting compiled successfully only errors are displayed on Android Studio. Try solutions provided in this link http://stackoverflow.com/questions/19508649/android-studio-says-cannot-resolve-symbol-but-project-compiles – Amod Gokhale Oct 28 '16 at 05:49

1 Answers1

0

Try Syncing the Gradle again. I also got stuck sometimes but it got fixed by removing some character from firebase dependency from Gradle and put it again, then sync the Gradle. P.S. Worked for me.

Aayush Thakur
  • 634
  • 1
  • 10
  • 22