Android Studio does not matter Adrequest or Adview

Asked

Viewed 223 times

1

The part that gets written android both turn red and no matter

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.seamusdawkins.R;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;




public class FirstFragment extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment

        View view = inflater.inflate(R.layout.fragment_home, container, false);

        AdView mAdView = (AdView) view.findViewById(R.id.ad);
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);

        return view;
    }


}

inserir a descrição da imagem aqui

I’ve tried to care otherwise by squeezing alt + enter no Adview however no import option appears

  • 1

    give a look at this link http://stackoverflow.com/questions/39675100/error-cant-resolve-symbol-adrequest-and-adview seems to be your problem

  • 1

    Gradle? Compile 'com.google.firebase:firebase-ads:9.6.1'

  • It was the same dependencies kk thank you

  • @Paiva was able to solve the problem or need more information. Did the answer below help?! hehe

1 answer

2


I think you have a serious problem with the AdView. Not to be appearing option to import, there is only one reason: Did not compile the lib in the Gradle. See how:

dependencies {
     compile 'com.google.firebase:firebase-ads:9.6.1'
}

In this option above, you will be importing the version 9.6.1, then it is advisable to enter the Release Notes firebase and check which version is more up-to-date.

Here’s this question about Error while using Adrequest has a more complete answer of how you can use the Admob.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.