Admob , ad colony Chartboost

Forum for the book "Beginning Android Games", see http://www.apress.com/9781430230427

Admob , ad colony Chartboost

Postby datamedic » Mon Jul 16, 2018 8:23 pm

Hello all

Im facing a problem that drives me crazy
i have setup a reward video on my game .

I have implemended a rewardedvideolistener and everything working as they should , as long as i use admob for my only source of reward videos.
Now i have added 2 mediation networks chartboost and ad colony.
Im able to see the video rewards but as soon as the video end im getting an error that im unable to understand how to impement

the error is the above and its the same for both adcolony and chartboost


java.lang.NoSuchMethodError: No interface method onVideoCompleted(Lcom/google/android/gms/ads/reward/mediation/MediationRewardedVideoAdAdapter;)V in class Lcom/google/android/gms/ads/reward/mediation/MediationRewardedVideoAdListener; or its super classes (declaration of 'com.google.android.gms.ads.reward.mediation.MediationRewardedVideoAdListener' appears in /data/app/mypackage/base.apk)
at com.jirbo.adcolony.AdColonyAdListener.onReward(AdColonyAdListener.java:138)
at com.adcolony.sdk.l$10.run(SourceFile:947)
at android.app.Activity.runOnUiThread(Activity.java:6029)
at com.adcolony.sdk.aw.a(SourceFile:212)
at com.adcolony.sdk.l.d(SourceFile:944)
at com.adcolony.sdk.l$15.a(SourceFile:217)
at com.adcolony.sdk.ag.a(SourceFile:188)
at com.adcolony.sdk.ag$2.run(SourceFile:157)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:165)

my code is this on android laucher class

Code: Select all
import Intreface.AdHandler;
import Intreface.GoogleServices;
import Intreface.IntestiliadAd;
import Intreface.VideoEventListener;


public class AndroidLauncher extends AndroidApplication implements GoogleServices, RewardedVideoAdListener, AdHandler , IntestiliadAd{
    private RewardedVideoAd adRewardedVideoView;
    private static final String REWARDED_VIDEO_AD_UNIT_ID = ".................................";
    private static String TAG = "AndroidLauncher";
    private static final String AD_UNIT_ID_INTERSTITIAL = ".............................";
    private static final String AD_UNIT_ID_BANNER = ".............................";
    private final int SHOW_ADS = 1;
    private final int HIDE_ADS = 0;
    protected AdView adView;
    private InterstitialAd interstitialAd;



    Handler handler = new Handler(){

        @Override
        public void handleMessage(Message msg) {
            switch (msg.what){
                case SHOW_ADS:
                    adView.setVisibility(View.VISIBLE);
                    break;
                case HIDE_ADS:
                    adView.setVisibility(View.GONE);
                    break;

            }
        }
    };


    private boolean is_video_ad_loaded;
    private VideoEventListener vel;
    private MediationAdapter mediationAdapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
     

        RelativeLayout layout = new RelativeLayout(this);

        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
        View gameView = initializeForView(new Farbbit(this,this,this), config);
        layout.addView(gameView);
        setupRewarded();
     
        interstitialAd = new InterstitialAd(this);
        adView = new AdView(this);
        adView.setAdListener(new AdListener() {
            @Override
            public void onAdLoaded() {
                super.onAdLoaded();
                Log.i(TAG, "Ad loaded...");
            }
        });

        adView.setAdSize(AdSize.SMART_BANNER);
        adView.setAdUnitId(AD_UNIT_ID_BANNER);
        interstitialAd.setAdUnitId(AD_UNIT_ID_INTERSTITIAL);

        interstitialAd.setAdListener(new AdListener() {

     @Override
     public void onAdLoaded() {

                     }
     @Override
      public void onAdClosed() {
                   }
    });



        AdRequest.Builder builder = new AdRequest.Builder();
        RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT
        );
        layout.addView(adView ,adParams);
   
        adView.loadAd(builder.build());
        setContentView(layout);

    }
     @Override
     public void showOrLoadInterstital() {
            try {
                  runOnUiThread(new Runnable() {
        public void run() {
                              if (interstitialAd.isLoaded()) {
                                    interstitialAd.show();

                                  }
                              else {
                                    AdRequest interstitialRequest = new AdRequest.Builder().build();
                                   interstitialAd.loadAd(interstitialRequest);

                                  }
                            }
         });
                } catch (Exception e) {
                }
          }

    @Override
    public void loadInterstital() {
        try {
            runOnUiThread(new Runnable() {
                public void run() {
        if (!interstitialAd.isLoaded()){
            AdRequest interstitialRequest = new AdRequest.Builder().build();
            interstitialAd.loadAd(interstitialRequest);
        }
    }   });
        } catch (Exception e) {
        }
    }

    public void loadRewardedVideoAd() {
        adRewardedVideoView.loadAd(REWARDED_VIDEO_AD_UNIT_ID, new AdRequest.Builder().build());
    }

    public void setupRewarded() {
        adRewardedVideoView = MobileAds.getRewardedVideoAdInstance(this);
        adRewardedVideoView.setRewardedVideoAdListener(this);
        loadRewardedVideoAd();
    }


    public boolean hasVideoLoaded() {
        if (is_video_ad_loaded) {
            return true;
        }
        runOnUiThread(new Runnable() {
            public void run() {
                if (!adRewardedVideoView.isLoaded()) {
                    loadRewardedVideoAd();
                }
            }
        });
        return false;
    }

    public void showRewardedVideoAd() {
        runOnUiThread(new Runnable() {
            public void run() {
                if (adRewardedVideoView.isLoaded()) {
                    adRewardedVideoView.show();
                } else {
                    loadRewardedVideoAd();
                }
            }
        });
    }

    @Override
    public void onRewarded(RewardItem reward) {
        if (vel != null) {
           
            vel.onRewardedEvent(reward.getType(), reward.getAmount());
        }
    }

    @Override
    public void onRewardedVideoAdLeftApplication() {

    }
    @Override
    public void onRewardedVideoAdFailedToLoad(int i) {

    }

   
    @Override
    public void onRewardedVideoAdClosed() {
        is_video_ad_loaded = false;
        loadRewardedVideoAd();
        if (vel != null) {
            vel.onRewardedVideoAdClosedEvent();
        }
    }

    @Override
    public void onRewardedVideoAdLoaded() {
        if (vel != null) {
            vel.onRewardedVideoAdLoadedEvent();
        }
        is_video_ad_loaded = true;
    }

    @Override
    public void onRewardedVideoAdOpened() {

    }

    @Override
    public void onRewardedVideoStarted() {

    }

    public void setVideoEventListener(VideoEventListener listener) {
        this.vel = listener;
    }

    @Override
    public void showAds(boolean show) {
        handler.sendEmptyMessage(show ? SHOW_ADS : HIDE_ADS);
    }


}


any help will be greatly appriciated..
datamedic
 
Posts: 3
Joined: Mon Jul 16, 2018 8:11 pm

Re: Admob , ad colony Chartboost

Postby datamedic » Wed Jul 18, 2018 8:19 am

no one had this issue ?
datamedic
 
Posts: 3
Joined: Mon Jul 16, 2018 8:11 pm


Return to Beginning Android Games

Who is online

Users browsing this forum: No registered users and 1 guest