2
votes

I have done Google Play Services Migration tutorial https://developers.google.com/mobile-ads-sdk/docs/admob/play-migration

and all is ok, but when I create Adview it finish.

Here is my code:

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

    private AdView adView;
   RelativeLayout layoutPublicidadHueco;

   .
   .
   .

    layoutPublicidadHueco = (RelativeLayout) findViewById(R.id.layoutAdver);
    AdView adView = new AdView(this);
    adView.setAdUnitId("my number");
    adView.setAdSize(AdSize.SMART_BANNER);

    adView.setAdListener(new AdListener() {
        public void onAdLoaded() {}
        public void onAdFailedToLoad(int errorcode) {}
            // Only implement methods you need.
        });
    layoutPublicidadHueco.removeAllViews();
    layoutPublicidadHueco.addView(adView);
    layoutPublicidadHueco.setVisibility(View.VISIBLE);
    AdRequest request = new AdRequest.Builder().build();
    adView.loadAd(request);

Thanks in advance.

1
You are going to have to provide more info. I presume you mean the App crashes. So show the stacktrace.William

1 Answers

2
votes

I solved it, I have added Google play services in libraries and I have added Google Play Services in external jar and I have exported it.

Thanks