error: cannot find symbol method setAdListener(<anonymous InterstitialAdListener>) & (<anonymous InterstitialAdListener>)

huangapple go评论78阅读模式
英文:

error: cannot find symbol method setAdListener(<anonymous InterstitialAdListener>) & (<anonymous InterstitialAdListener>)

问题

error: 无法找到符号方法 setAdListener(<匿名 AdListener>)
error: 无法找到符号方法 setAdListener(<匿名 InterstitialAdListener>)

com.facebook.ads.AdView adView_banner = new com.facebook.ads.AdView(this, getString(R.string.facebook_banner_id), AdSize.BANNER_HEIGHT_50);

// 找到广告容器
LinearLayout adContainer = (LinearLayout) findViewById(R.id.adView);

// 将广告视图添加到您的活动布局
adContainer.addView(adView_banner);

adView_banner.setAdListener(new com.facebook.ads.AdListener() {
@Override
public void onError(Ad ad, AdError adError) {
Log.i("ERR", "" + adError.getErrorMessage());
}
});

英文:

error: cannot find symbol method setAdListener(<anonymous AdListener>)
error: cannot find symbol method setAdListener(<anonymous InterstitialAdListener>)

com.facebook.ads.AdView adView_banner = new com.facebook.ads.AdView(this, getString(R.string.facebook_banner_id), AdSize.BANNER_HEIGHT_50);

    // Find the Ad Container
    LinearLayout adContainer = (LinearLayout) findViewById(R.id.adView);

    // Add the ad view to your activity layout
    adContainer.addView(adView_banner);

    adView_banner.setAdListener(new com.facebook.ads.AdListener() {
        @Override
        public void onError(Ad ad, AdError adError) {
            Log.i(&quot;ERR&quot;,&quot;&quot;+adError.getErrorMessage());
        }

答案1

得分: 1

Facebook已更新其当前的SDK,针对您的情况,您需要更改您的代码以引用以下链接:

https://developers.facebook.com/docs/audience-network/guides/ad-formats/banner/android

AdListener adListener = new AdListener() {
    @Override
    public void onError(Ad ad, AdError adError) {
        // 广告错误回调
        Toast.makeText(
                MainActivity.this,
                "错误:" + adError.getErrorMessage(),
                Toast.LENGTH_LONG)
                .show();
    }

    @Override
    public void onAdLoaded(Ad ad) {
        // 广告加载完成回调
    }

    @Override
    public void onAdClicked(Ad ad) {
        // 广告被点击回调
    }

    @Override
    public void onLoggingImpression(Ad ad) {
        // 广告展示印象被记录回调
    }
};

// 请求广告
adView.loadAd(adView.buildLoadAdConfig().withAdListener(adListener).build());
英文:

Facebook has updated their current SDK, for your case change your code to
reference
https://developers.facebook.com/docs/audience-network/guides/ad-formats/banner/android

AdListener adListener = new AdListener() {
            @Override
            public void onError(Ad ad, AdError adError) {
                // Ad error callback
                Toast.makeText(
                        MainActivity.this,
                        &quot;Error: &quot; + adError.getErrorMessage(),
                        Toast.LENGTH_LONG)
                        .show();
            }

            @Override
            public void onAdLoaded(Ad ad) {
                // Ad loaded callback
            }

            @Override
            public void onAdClicked(Ad ad) {
                // Ad clicked callback
            }

            @Override
            public void onLoggingImpression(Ad ad) {
                // Ad impression logged callback
            }
        };

        // Request an ad
        adView.loadAd(adView.buildLoadAdConfig().withAdListener(adListener).build());

huangapple
  • 本文由 发表于 2020年10月8日 21:31:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/64263608.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定