jeudi 20 avril 2017

Class 'Anonymous class derived from AdListener' must either be declared abstract or implement abstract method 'onLoggingImpressionMethod(Ad)'

Error: Class 'Anonymous class derived from AdListener' must either be declared abstract or implement abstract method 'onLoggingImpressionMethod(Ad)' in 'AdListener'

Here is my code:

public class AdvancedAnswerListAdapter extends RecyclerView.Adapter implements Constants {

private List<Answer> items = new ArrayList<>();

private Context context;

ImageLoader imageLoader = App.getInstance().getImageLoader();

private OnItemMenuButtonClickListener onItemMenuButtonClickListener;

public interface OnItemMenuButtonClickListener {

    void onItemClick(View view, Answer obj, int actionId, int position);

public void setOnMoreButtonClickListener(final OnItemMenuButtonClickListener onItemMenuButtonClickListener) {

    this.onItemMenuButtonClickListener = onItemMenuButtonClickListener;

// FB Native AD
private NativeAd mFBNativeAd;

public class ViewHolder extends RecyclerView.ViewHolder {

    public CircularImageView mItemAuthorPhoto, mItemAuthorIcon;
    public TextView mItemAuthor, mItemAuthorUsername;
    public ImageView mItemAuthorOnlineIcon, mItemPlayVideo;
    public ImageView mItemMenuButton;
    public ResizableImageView mItemImg;
    public ImageView mItemLikeImg, mItemAnswerImg, mItemShareImg;
    public TextView mItemLikesCount, mItemAnswersCount;
    public EmojiconTextView mItemDescription;
    public TextView mItemTimeAgo;
    public ProgressBar mProgressBar;
    public MaterialRippleLayout mItemLikeButton, mItemAnswerButton, mItemShareButton;

    public LinearLayout mLinkContainer;
    public ImageView mLinkImage;
    public TextView mLinkTitle;
    public TextView mLinkDescription;

    // FB Native Ad Views
    ImageView nativeAdIcon ;
    TextView nativeAdTitle;
    MediaView nativeAdMedia ;
    TextView nativeAdSocialContext ;
    TextView nativeAdBody ;
    Button nativeAdCallToAction ;
    LinearLayout adContainer,adChoicesContainer ;

    public ViewHolder(View v, int itemType) {


        if (itemType == 0) {

            mItemAuthorPhoto = (CircularImageView) v.findViewById(;
            mItemAuthorIcon = (CircularImageView) v.findViewById(;

            mItemAuthor = (TextView) v.findViewById(;
            mItemAuthorOnlineIcon = (ImageView) v.findViewById(;
            mItemAuthorUsername = (TextView) v.findViewById(;

            mItemImg = (ResizableImageView) v.findViewById(;
            mItemDescription = (EmojiconTextView) v.findViewById(;

            mItemPlayVideo = (ImageView) v.findViewById(;

            mItemMenuButton = (ImageView) v.findViewById(;
            mItemLikeImg = (ImageView) v.findViewById(;
            mItemAnswerImg = (ImageView) v.findViewById(;
            mItemShareImg = (ImageView) v.findViewById(;
            mItemTimeAgo = (TextView) v.findViewById(;

            mItemLikesCount = (TextView) v.findViewById(;
            mItemAnswersCount = (TextView) v.findViewById(;

            mProgressBar = (ProgressBar) v.findViewById(;

            mItemLikeButton = (MaterialRippleLayout) v.findViewById(;
            mItemAnswerButton = (MaterialRippleLayout) v.findViewById(;
            mItemShareButton = (MaterialRippleLayout) v.findViewById(;

            mLinkContainer = (LinearLayout) v.findViewById(;
            mLinkTitle = (TextView) v.findViewById(;
            mLinkDescription = (TextView) v.findViewById(;
            mLinkImage = (ImageView) v.findViewById(;

        } else if (itemType == 1) {

            nativeAdIcon = (ImageView) v.findViewById(;
            nativeAdTitle = (TextView) v.findViewById(;
            nativeAdMedia = (MediaView) v.findViewById(;
            nativeAdSocialContext = (TextView) v.findViewById(;
            nativeAdBody = (TextView) v.findViewById(;
            nativeAdCallToAction = (Button) v.findViewById(;
            adContainer = (LinearLayout) v.findViewById(;
            adChoicesContainer = (LinearLayout) v.findViewById(;


public AdvancedAnswerListAdapter(Context ctx, List<Answer> items) {

    this.context = ctx;
    this.items = items;

    if (imageLoader == null) {

        imageLoader = App.getInstance().getImageLoader();

private void setUpFacebookAD() {
    mFBNativeAd = new NativeAd(context, "xxxxxxxxxxxxxxx_xxxxxxxxxxxxxxx");
    mFBNativeAd.setAdListener(new {

        public void onError(Ad ad, AdError error) {
            // Ad error callback
            Log.i("fb native ad","on Error" + " "+ error.getErrorMessage());

        public void onAdLoaded(Ad ad) {
            // Ad loaded callback
            Log.i("FB native ad ", "On Ad loaded");


        public void onAdClicked(Ad ad) {
            // Ad clicked callback
            Log.i("FB natvie Ad" , "onAd clicked");

The is red color underlined. I tried reduced it to AdListener only but still getting error. It only happened after i upgraded the jdk version and the location of jdk. Before the upgrade the code is working. How can I get it to work?


0 commentaires:

Enregistrer un commentaire