错误:类型不兼容:<匿名AdListener>无法转换为NativeAdListener

时间:2019-10-11 11:40:44

标签: android native-ads

重建或运行应用程序时发现此错误:

public void showHomeScreenFacebookAds(View rootView) {

    AudienceNetworkAds.initialize(this);
    try {
        this.nativeExitAd = new NativeAd(this, getResources().getString(R.string.fb_exit_native_id));
        this.progressBarExitRefresh = rootView.findViewById(R.id.exit_progress);
        this.nativeAdContainerExitAds = rootView.findViewById(R.id.exit_ad_container);
        this.progressBarExitRefresh.setVisibility(View.VISIBLE);
        this.nativeExitAd.setAdListener(new com.facebook.ads.AdListener() {
            public void onError(Ad ad, AdError adError) {
                CollageActivity.this.nativeAdContainerExitAds.setVisibility(View.INVISIBLE);
                CollageActivity.this.progressBarExitRefresh.setVisibility(View.INVISIBLE);
            }

1 个答案:

答案 0 :(得分:0)

从给定的相对较少的上下文中,我只能告诉您,setAdListener()需要一个NativeAdListener类型的参数,但是您在调用中创建的AdListener不是该类型的,也不是它的子类,并且也不实现该接口。

要说明为什么会这样,或者如何正确完成,需要更多上下文信息,例如您要做什么,工作的环境等。