noclassdeffounderror com.google.android.gms.ads.AdView

时间:2014-02-04 13:48:18

标签: android admob google-play-services

我已完成Google Play服务迁移教程https://developers.google.com/mobile-ads-sdk/docs/admob/play-migration

一切都很好,但是当我创建Adview时,它就完成了。

这是我的代码:

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);

提前致谢。

1 个答案:

答案 0 :(得分:2)

我解决了这个问题,我在图书馆中添加了Google Play服务,并在外部jar中添加了Google Play服务,并将其导出。

由于